twinkle
twinkle copied to clipboard
warnings: Add limit on hour count in timer2str() [-Wformat-truncation]
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.
(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:)