git-svn: trunk@3273
Tomasz Kojm authored on 2007/10/06 08:48:44... | ... |
@@ -279,7 +279,9 @@ int main(int argc, char **argv) |
279 | 279 |
if(!cfgopt(copt, "Foreground")->enabled) { |
280 | 280 |
daemonize(); |
281 | 281 |
if(!debug_mode) |
282 |
- chdir("/"); |
|
282 |
+ if(chdir("/") == -1) |
|
283 |
+ logg("^Can't change current working directory to root\n"); |
|
284 |
+ |
|
283 | 285 |
} else |
284 | 286 |
foreground = 1; |
285 | 287 |
|
... | ... |
@@ -204,8 +204,8 @@ static int dsstream(int sockd, const struct optstruct *opt) |
204 | 204 |
return 2; |
205 | 205 |
} |
206 | 206 |
|
207 |
- memset(buff, 0, sizeof(buff)); |
|
208 | 207 |
while(loopw) { |
208 |
+ memset(buff, 0, sizeof(buff)); |
|
209 | 209 |
read(sockd, buff, sizeof(buff)); |
210 | 210 |
if((pt = strstr(buff, "PORT"))) { |
211 | 211 |
pt += 5; |
... | ... |
@@ -107,11 +107,16 @@ static int scanstdin(const struct cl_engine *engine, const struct cl_limits *lim |
107 | 107 |
|
108 | 108 |
if(!(fs = fopen(file, "wb"))) { |
109 | 109 |
logg("!Can't open %s for writing\n", file); |
110 |
+ free(file); |
|
110 | 111 |
return 63; |
111 | 112 |
} |
112 | 113 |
|
113 | 114 |
while((ret = fread(buff, 1, FILEBUFF, stdin))) |
114 |
- fwrite(buff, 1, ret, fs); |
|
115 |
+ if(fwrite(buff, 1, ret, fs) < ret) { |
|
116 |
+ logg("!Can't write to %s\n", file); |
|
117 |
+ free(file); |
|
118 |
+ return 58; |
|
119 |
+ } |
|
115 | 120 |
|
116 | 121 |
fclose(fs); |
117 | 122 |
|
... | ... |
@@ -460,7 +465,10 @@ static int clamav_unpack(const char *prog, const char **args, const char *tmpdir |
460 | 460 |
} |
461 | 461 |
} |
462 | 462 |
#endif |
463 |
- chdir(tmpdir); |
|
463 |
+ if(chdir(tmpdir) == -1) { |
|
464 |
+ fprintf(stderr, "ERROR: chdir(%s) failed\n", tmpdir); |
|
465 |
+ exit(1); |
|
466 |
+ } |
|
464 | 467 |
|
465 | 468 |
if(printinfected) { |
466 | 469 |
fdevnull = open("/dev/null", O_WRONLY); |
... | ... |
@@ -171,7 +171,11 @@ int filecopy(const char *src, const char *dest) |
171 | 171 |
} |
172 | 172 |
|
173 | 173 |
while((bytes = read(s, buffer, FILEBUFF)) > 0) |
174 |
- write(d, buffer, bytes); |
|
174 |
+ if(write(d, buffer, bytes) < bytes) { |
|
175 |
+ close(s); |
|
176 |
+ close(d); |
|
177 |
+ return -1; |
|
178 |
+ } |
|
175 | 179 |
|
176 | 180 |
close(s); |
177 | 181 |
/* njh@bandsman.co.uk: check result of close for NFS file */ |