[Git][NTPsec/ntpsec][master] ieee754io: fix a bug found with new tests

Gary E. Miller gitlab at mg.gitlab.com
Tue Apr 4 23:56:50 UTC 2017


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
afd6f6c8 by Gary E. Miller at 2017-04-04T16:55:29-07:00
ieee754io: fix a bug found with new tests

floats were not allowed to be as big as they can be.

- - - - -


1 changed file:

- libparse/ieee754io.c


Changes:

=====================================
libparse/ieee754io.c
=====================================
--- a/libparse/ieee754io.c
+++ b/libparse/ieee754io.c
@@ -149,6 +149,7 @@ fetch_ieee754(
   unsigned long mantissa_high;
   unsigned long characteristic;
   long exponent;
+  unsigned int maxexp_lfp;  /* maximum exponent that fits in an l_fp */
 #ifdef DEBUG_PARSELIB
   int length;
 #endif
@@ -164,6 +165,7 @@ fetch_ieee754(
 #ifdef DEBUG_PARSELIB
       length = 8;
 #endif
+      maxexp_lfp = 31;
       mbits  = 52;
       bias   = 1023;
       maxexp = 2047;
@@ -173,6 +175,7 @@ fetch_ieee754(
 #ifdef DEBUG_PARSELIB
       length = 4;
 #endif
+      maxexp_lfp = 127;
       mbits  = 23;
       bias   = 127;
       maxexp = 255;
@@ -287,7 +290,7 @@ fetch_ieee754(
        */
       exponent = characteristic - bias;
 
-      if (exponent > 31)	/* sorry - hardcoded */
+      if (exponent > maxexp_lfp)	/* sorry an l_fp only so long */
 	{
 	  /*
 	   * overflow only in respect to NTP-FP representation



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/afd6f6c86a8f591e35d1f32cd3f33f74392e47c8
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170404/6b55b73b/attachment.html>


More information about the vc mailing list