[Git][NTPsec/ntpsec][master] 2 commits: Add an overflow warning.
Eric S. Raymond
gitlab at mg.gitlab.com
Fri Sep 1 10:51:55 UTC 2017
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
9cec5fed by Eric S. Raymond at 2017-09-01T06:45:58-04:00
Add an overflow warning.
- - - - -
8e7e0677 by Eric S. Raymond at 2017-09-01T06:51:42-04:00
Fix brown0paper-bag bug in clocktime computation.
- - - - -
2 changed files:
- libntp/clocktime.c
- tests/libntp/clocktime.c
Changes:
=====================================
libntp/clocktime.c
=====================================
--- a/libntp/clocktime.c
+++ b/libntp/clocktime.c
@@ -86,12 +86,13 @@ clocktime(
* a trashed or zeroed system clock.
*
* Warning: the hack in the NMEA driver that rectifies 4-digit
- * yearts from 2-digit ones has an expiration date in 2399.
+ * years from 2-digit ones has an expiration date in 2399.
* After that this code will go badly wrong.
*/
if (year > 1970) {
*yearstart = year_to_ntp(year);
- return (int32_t)*yearstart + tmp;
+ *ts_ui = (int32_t)*yearstart + tmp;
+ return true;
}
/*
=====================================
tests/libntp/clocktime.c
=====================================
--- a/tests/libntp/clocktime.c
+++ b/tests/libntp/clocktime.c
@@ -56,6 +56,11 @@ TEST(clocktime, CurrentYearExplicit) {
TEST_ASSERT_TRUE(clocktime(year, yday, hour, minute, second,
tzoff, timestamp, &yearstart, &actual));
+ /* If this assertion fails with "Expected 3486372600 was
+ * 104913720" that's a 32-bit integer overflow and your compiler
+ * is failing to cast to int properly inside clocktime.
+ * Observed on Mac OS X.
+ */
TEST_ASSERT_EQUAL(expected, actual);
TEST_ASSERT_EQUAL(yearstart, 3471292800);
}
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/48d36a61e466c6988e0bf56b6dd8109d2fba222d...8e7e0677d06589255a1ff0f5eac22082031b4d60
---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/48d36a61e466c6988e0bf56b6dd8109d2fba222d...8e7e0677d06589255a1ff0f5eac22082031b4d60
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170901/6d81bb6e/attachment.html>
More information about the vc
mailing list