Commit 30948d7f authored by Dag Erling Smørgrav's avatar Dag Erling Smørgrav

Fix some style nits and an out-of-bounds array dereference.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1595 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 1bd7940f
......@@ -119,20 +119,23 @@ trimline(const char *str, const char *end)
* hostname and returning a struct with necessary
* connection info.
*/
static struct vss_addr*
init_connection(const char* address)
static struct vss_addr *
init_connection(const char *address)
{
struct vss_addr **ta;
struct vss_addr *tap;
char *addr, *port;
int i, n;
XXXAZ(VSS_parse(address, &addr, &port));
XXXAN(n = VSS_resolve(addr, port, &ta));
if (VSS_parse(address, &addr, &port) != 0) {
fprintf(stderr, "Invalid address\n");
exit(2);
}
n = VSS_resolve(addr, port, &ta);
free(addr);
free(port);
if (n == 0) {
fprintf(stderr, "Could not open TELNET port\n");
fprintf(stderr, "Could not connect to server\n");
exit(2);
}
for (i = 1; i < n; ++i) {
......@@ -174,7 +177,7 @@ read_line(char **line)
exit(1);
}
nbuf += i;
if (buf[nbuf-2] == '\r' && buf[nbuf-1] == '\n')
if (nbuf >= 2 && buf[nbuf-2] == '\r' && buf[nbuf-1] == '\n')
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment