Browse code

Fix clamdscan infinite loop

Shawn Webb authored on 2014/05/13 10:17:04
Showing 2 changed files
... ...
@@ -100,6 +100,11 @@ static int isremote(const struct optstruct *opts) {
100 100
 
101 101
     opt = optget(clamdopts, "TCPAddr");
102 102
     while (opt) {
103
+        if (!(opt))
104
+            break;
105
+        if (strcmp(opt->name, "TCPAddr"))
106
+            break;
107
+
103 108
         if (opt->enabled)
104 109
             ipaddr = (!strcmp(opt->strarg, "any") ? NULL : opt->strarg);
105 110
         else
... ...
@@ -112,6 +117,7 @@ static int isremote(const struct optstruct *opts) {
112 112
 
113 113
         if ((res = getaddrinfo(ipaddr, port, &hints, &info))) {
114 114
             logg("!Can't lookup clamd hostname: %s\n", gai_strerror(res));
115
+            opt = opt->next;
115 116
             continue;
116 117
         }
117 118
 
... ...
@@ -94,6 +94,11 @@ int dconnect() {
94 94
 
95 95
     opt = optget(clamdopts, "TCPAddr");
96 96
     while (opt) {
97
+        if (!(opt))
98
+            break;
99
+        if (strcmp(opt->name, "TCPAddr"))
100
+            break;
101
+
97 102
         memset(&hints, 0x00, sizeof(struct addrinfo));
98 103
         hints.ai_family = AF_UNSPEC;
99 104
         hints.ai_socktype = SOCK_STREAM;