Skip to content

Tags: jay/battstatus

Tags

v1.4

Toggle v1.4's commit message
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

v1.3

Toggle v1.3's commit message
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

v1.2

Toggle v1.2's commit message
Add -a option to show lifetime as an average

The "Average Lifetime" option. Show lifetime as an average of the last
-a <minutes>.

v1.1

Toggle v1.1's commit message
Add pwrtest download link to the README

v1.0

Toggle v1.0's commit message
Fix build for Microsoft and mingw-w64 compilers

Prior to this change only original mingw worked.