]> err.no Git - varnish/commitdiff
Make sure we don't overflow the line buffer
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 5 Aug 2006 12:22:46 +0000 (12:22 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 5 Aug 2006 12:22:46 +0000 (12:22 +0000)
Remove unused #include

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@662 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_cli.c

index 9a5c7a29717ef1ea49f29096e7fb0824254905d1..5498b5e0153c61f998c1d3d5a28b8cf1199ad072 100644 (file)
@@ -9,7 +9,6 @@
 #include <unistd.h>
 #include <poll.h>
 
-#include "libvarnish.h"
 #include "shmlog.h"
 #include "cli.h"
 #include "cli_priv.h"
@@ -72,7 +71,7 @@ CLI_Init(void)
                i = poll(pfd, 1, 5000);
                if (i == 0)
                        continue;
-               if (nbuf == lbuf) {
+               if ((nbuf + 2) >= lbuf) {
                        lbuf += lbuf;
                        buf = realloc(buf, lbuf);
                        assert(buf != NULL);
@@ -80,6 +79,7 @@ CLI_Init(void)
                i = read(heritage.fds[2], buf + nbuf, lbuf - nbuf);
                if (i <= 0) {
                        VSL(SLT_Error, 0, "CLI read %d (errno=%d)", i, errno);
+                       free(buf);
                        return;
                }
                nbuf += i;
@@ -94,6 +94,7 @@ CLI_Init(void)
                i = cli_writeres(heritage.fds[1], cli);
                if (i) {
                        VSL(SLT_Error, 0, "CLI write failed (errno=%d)", errno);
+                       free(buf);
                        return;
                }
                VSL(SLT_CLI, 0, "Wr %d %d %s",