another changed behaviour

Gary E. Miller gem at rellim.com
Mon Feb 4 20:58:04 UTC 2019


Yo Achim!

On Mon, 04 Feb 2019 21:37:35 +0100
Achim Gratz via devel <devel at ntpsec.org> wrote:

> This defect bisects to the unlikely commit:

here is the entire change:

@@ -1198,21 +1198,14 @@ ctl_putdblf(
        double          d
        )
 {
-       char *cp;
-       const char *cq;
-       char buffer[200];
+        char buffer[200];
+        char buf[50];
 
-       cp = buffer;
-       cq = tag;
-       while (*cq != '\0' && cp < buffer + sizeof(buffer) - 1)
-               *cp++ = *cq++;
-       *cp++ = '=';
-       INSIST((size_t)(cp - buffer) < sizeof(buffer));
-       snprintf(cp, sizeof(buffer) - (size_t)(cp - buffer),
-                 use_f ? "%.*f" : "%.*g",
-           precision, d);
-       cp += strlen(cp);
-       ctl_putdata(buffer, (unsigned)(cp - buffer), false);


The end result is:

        char buffer[200];
        char buf[50];

        strlcpy(buffer, tag, sizeof(buffer));
        snprintf(buf, sizeof(buf), use_f ? "=%.*f" : "%.*g", precision, d);
        strlcat(buffer, buf, sizeof(buffer));

        ctl_putdata(buffer, strlen(buffer), false);

Am I missing something very obvious?

RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
	gem at rellim.com  Tel:+1 541 382 8588

	    Veritas liberabit vos. -- Quid est veritas?
    "If you can’t measure it, you can’t improve it." - Lord Kelvin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 851 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ntpsec.org/pipermail/devel/attachments/20190204/bcac81b2/attachment.bin>


More information about the devel mailing list