twinkle icon indicating copy to clipboard operation
twinkle copied to clipboard

warnings: Add limit on hour count in timer2str() [-Wformat-truncation]

Open fbriere opened this issue 3 years ago • 1 comments

As the C specification does not impose an upper bound on integer sizes, there is no limit on the length of the string generated by timer2str() either. On a 64-bit system, a buffer overflow could (theoretically) occur, given ridiculously large values.

This adds an (arbitrary) limit of 1000 hours, corresponding to a duration of over a month, which should be more than sufficient.

fbriere avatar Jun 11 '22 19:06 fbriere

(While -Wformat-truncation is not enabled by default, it is added by dpkg-buildflags when building a Debian package, which is why it was driving me nuts just a little bit. :smile:)

fbriere avatar Jun 11 '22 20:06 fbriere