Tags: jay/battstatus
Tags
Omit timestamp in window title When option -w is used the one-liner status is shown in the window title. Prior to this change it was shown with the timestamp prefix which could use all the viewable title text in a window thumbnail. Suggested-by: Bryan Kirk Closes #5
Fix out-of-bounds read in ChemistryStr
- Check BATTERY_INFORMATION Chemistry[4] for null terminator.
Chemistry is a string that is "not necessarily zero-terminated".
Prior to this change ChemistryStr() did not check for null and
incorrectly used sizeof to get the read size of parameter
UCHAR Chemistry[4] which decays to UCHAR *Chemistry.
For 32-bit builds ChemistryStr happened to work by luck, though it may
have read the null into std::string. MS currently uses only strings of
length 3 or 4, and the size of *Chemistry is 4 so ChemistryStr never
read past 4 bytes. For example {'N','i','Z','n'} or {'R','A','M','\0'}.
For 64-bit builds the pointer size is 8 and it read at least 4 bytes too
many.
Ref: https://docs.microsoft.com/en-us/windows/win32/power/battery-information-str