Browse code

use PATH_MAX instead of hardcoded limit (bb #930)

git-svn: trunk@4055

Török Edvin authored on 2008/08/01 23:50:33
Showing 1 changed files
... ...
@@ -26,6 +26,9 @@
26 26
 #include <sys/types.h>
27 27
 #include <sys/stat.h>
28 28
 #include <sys/socket.h>
29
+#ifdef HAVE_SYS_LIMITS_H
30
+#include <sys/limits.h>
31
+#endif
29 32
 #include <sys/un.h>
30 33
 #include <netinet/in.h>
31 34
 #include <arpa/inet.h>
... ...
@@ -230,21 +233,25 @@ static int dsstream(int sockd, const struct optstruct *opt)
230 230
     return infected;
231 231
 }
232 232
 
233
+#ifndef PATH_MAX
234
+#define PATH_MAX 1024
235
+#endif
236
+
233 237
 static char *abpath(const char *filename)
234 238
 {
235 239
 	struct stat foo;
236
-	char *fullpath, cwd[200];
240
+	char *fullpath, cwd[PATH_MAX + 1];
237 241
 
238 242
     if(stat(filename, &foo) == -1) {
239 243
 	logg("^Can't access file %s\n", filename);
240 244
 	perror(filename);
241 245
 	return NULL;
242 246
     } else {
243
-	fullpath = malloc(200 + strlen(filename) + 10);
247
+	fullpath = malloc(PATH_MAX + strlen(filename) + 10);
244 248
 #ifdef C_CYGWIN
245 249
 	sprintf(fullpath, "%s", filename);
246 250
 #else
247
-	if(!getcwd(cwd, 200)) {
251
+	if(!getcwd(cwd, PATH_MAX)) {
248 252
 	    logg("^Can't get absolute pathname of current working directory.\n");
249 253
 	    return NULL;
250 254
 	}
... ...
@@ -368,7 +375,7 @@ int get_clamd_version(const struct optstruct *opt)
368 368
 
369 369
 int client(const struct optstruct *opt, int *infected)
370 370
 {
371
-	char cwd[200], *fullpath;
371
+	char cwd[PATH_MAX+1], *fullpath;
372 372
 	int sockd, ret, errors = 0;
373 373
 	struct stat sb;
374 374
 	const char *scantype = "CONTSCAN";
... ...
@@ -382,7 +389,7 @@ int client(const struct optstruct *opt, int *infected)
382 382
     /* parse argument list */
383 383
     if(opt->filename == NULL || strlen(opt->filename) == 0) {
384 384
 	/* scan current directory */
385
-	if(!getcwd(cwd, 200)) {
385
+	if(!getcwd(cwd, PATH_MAX)) {
386 386
 	    logg("^Can't get absolute pathname of current working directory.\n");
387 387
 	    return 2;
388 388
 	}