Mailing List Archive

r1705 - trunk/varnish-cache/lib/libvarnish
Author: phk
Date: 2007-07-15 13:25:27 +0200 (Sun, 15 Jul 2007)
New Revision: 1705

Modified:
trunk/varnish-cache/lib/libvarnish/cli_common.c
Log:
From the "What has the world come to ?" department:

It used to be that sscanf(3) would walk along the proffered string
and do what the format string was told, and as long as the format
terminated before the input string, the NUL termination was not
relevant.

Sometime in the last 20 years, sscanf started doing a strlen on the
passed argument changing this behaviour.

Give sscanf the NUL it wants.



Modified: trunk/varnish-cache/lib/libvarnish/cli_common.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/cli_common.c 2007-07-15 11:08:48 UTC (rev 1704)
+++ trunk/varnish-cache/lib/libvarnish/cli_common.c 2007-07-15 11:25:27 UTC (rev 1705)
@@ -154,6 +154,7 @@
assert(i == CLI_LINE0_LEN);
assert(res[3] == ' ');
assert(res[CLI_LINE0_LEN - 1] == '\n');
+ res[CLI_LINE0_LEN - 1] = '\0';
j = sscanf(res, "%u %u\n", &u, &v);
assert(j == 2);
if (status != NULL)