]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] halog: correctly handle truncated last line
authorWilly Tarreau <w@1wt.eu>
Sat, 9 Jul 2011 12:28:01 +0000 (14:28 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 11 Jul 2011 04:48:02 +0000 (06:48 +0200)
If last line is truncated (eg: truncated file), then halog would loop on
it forever.

contrib/halog/fgets2-64.c
contrib/halog/fgets2.c

index 236b970dd2dbb6e87bb7feb1ff0da885822018b5..9aae45465c06fc453e84b0e8e9a85908427fb8e8 100644 (file)
@@ -155,6 +155,7 @@ const char *fgets2(FILE *stream)
                                return NULL;
 
                        *end = '\0';
+                       end = line; /* ensure we stop next time */
                        return line;
                }
 
index 61d9ef58c9abf840dad799f40777156ca2fe984f..6c5bc6b0a9ef2f53c13e9ed87d057df6e6d947a6 100644 (file)
@@ -130,6 +130,7 @@ const char *fgets2(FILE *stream)
                                return NULL;
 
                        *end = '\0';
+                       end = line; /* ensure we stop next time */
                        return line;
                }