From 6432bbfbfb05ee03d3059347aa0e3852d474c282 Mon Sep 17 00:00:00 2001 From: Shawn Webb Date: Tue, 13 May 2014 11:10:18 -0400 Subject: [PATCH] Lets try this TCPAddr option parsing in clamdscan one more time --- clamdscan/client.c | 12 ++++-------- clamdscan/proto.c | 12 +++++++----- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/clamdscan/client.c b/clamdscan/client.c index 705b858ab..813079ce8 100644 --- a/clamdscan/client.c +++ b/clamdscan/client.c @@ -100,13 +100,9 @@ static int isremote(const struct optstruct *opts) { opt = optget(clamdopts, "TCPAddr"); while (opt) { - if (strcmp(opt->name, "TCPAddr")) - break; - - if (opt->enabled) + ipaddr = NULL; + if (opt->strarg) ipaddr = (!strcmp(opt->strarg, "any") ? NULL : opt->strarg); - else - ipaddr = NULL; memset(&hints, 0x00, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; @@ -115,7 +111,7 @@ static int isremote(const struct optstruct *opts) { if ((res = getaddrinfo(ipaddr, port, &hints, &info))) { logg("!Can't lookup clamd hostname: %s\n", gai_strerror(res)); - opt = opt->next; + opt = opt->nextarg; continue; } @@ -158,7 +154,7 @@ static int isremote(const struct optstruct *opts) { freeaddrinfo(info); - opt = opt->next; + opt = opt->nextarg; } return 0; diff --git a/clamdscan/proto.c b/clamdscan/proto.c index e4f44b363..0beecc2dc 100644 --- a/clamdscan/proto.c +++ b/clamdscan/proto.c @@ -77,6 +77,7 @@ int dconnect() { const struct optstruct *opt; struct addrinfo hints, *info, *p; char port[10]; + char *ipaddr; #ifndef _WIN32 opt = optget(clamdopts, "LocalSocket"); @@ -94,16 +95,17 @@ int dconnect() { opt = optget(clamdopts, "TCPAddr"); while (opt) { - if (strcmp(opt->name, "TCPAddr")) - break; + ipaddr = NULL; + if (opt->strarg) + ipaddr = (!strcmp(opt->strarg, "any") ? NULL : opt->strarg); memset(&hints, 0x00, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; - if ((res = getaddrinfo(opt->strarg, port, &hints, &info))) { - opt = opt->next; + if ((res = getaddrinfo(ipaddr, port, &hints, &info))) { + opt = opt->nextarg; continue; } @@ -124,7 +126,7 @@ int dconnect() { freeaddrinfo(info); - opt = opt->next; + opt = opt->nextarg; } return -1;