Lets try this TCPAddr option parsing in clamdscan one more time

This commit is contained in:
Shawn Webb
2014-05-13 11:10:18 -04:00
parent 0d883e3164
commit 6432bbfbfb
2 changed files with 11 additions and 13 deletions

View File

@@ -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;

View File

@@ -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;