View | Details | Raw Unified | Return to bug 8993
Collapse All | Expand All

(-)b/clamd/clamd.c (-1 / +1 lines)
 Lines 275-281   int main(int argc, char **argv) Link Here 
275
275
276
#ifdef C_LINUX
276
#ifdef C_LINUX
277
    procdev = 0;
277
    procdev = 0;
278
    if(STAT("/proc", &sb) != -1 && !sb.st_size)
278
    if(CLAMSTAT("/proc", &sb) != -1 && !sb.st_size)
279
	procdev = sb.st_dev;
279
	procdev = sb.st_dev;
280
#endif
280
#endif
281
281
(-)b/clamd/localserver.c (-1 / +1 lines)
 Lines 92-98   int localserver(const struct optstruct *opts) Link Here 
92
		    close(sockfd);
92
		    close(sockfd);
93
		    return -1;
93
		    return -1;
94
		}
94
		}
95
	    } else if(STAT(server.sun_path, &foo) != -1) {
95
	    } else if(CLAMSTAT(server.sun_path, &foo) != -1) {
96
		logg("!LOCAL: Socket file %s exists. Either remove it, or configure a different one.\n", server.sun_path);
96
		logg("!LOCAL: Socket file %s exists. Either remove it, or configure a different one.\n", server.sun_path);
97
		close(sockfd);
97
		close(sockfd);
98
		return -1;
98
		return -1;
(-)b/clamd/others.c (-1 / +1 lines)
 Lines 876-882   fan_checkowner (int pid, const struct optstruct *opts) Link Here 
876
        return 0;
876
        return 0;
877
877
878
    snprintf (path, sizeof (path), "/proc/%u", pid);
878
    snprintf (path, sizeof (path), "/proc/%u", pid);
879
    if (STAT (path, &sb) == 0)
879
    if (CLAMSTAT (path, &sb) == 0)
880
    {
880
    {
881
        while (opt)
881
        while (opt)
882
        {
882
        {
(-)b/clamd/scanner.c (-1 / +1 lines)
 Lines 325-331   int scan_pathchk(const char *path, struct cli_ftw_cbdata *data) Link Here 
325
    }
325
    }
326
326
327
    if(!optget(scandata->opts, "CrossFilesystems")->enabled) {
327
    if(!optget(scandata->opts, "CrossFilesystems")->enabled) {
328
	if(STAT(path, &statbuf) == 0) {
328
	if(CLAMSTAT(path, &statbuf) == 0) {
329
	    if(statbuf.st_dev != scandata->dev) {
329
	    if(statbuf.st_dev != scandata->dev) {
330
		if(scandata->type != TYPE_MULTISCAN)
330
		if(scandata->type != TYPE_MULTISCAN)
331
		    conn_reply_single(scandata->conn, path, "Excluded (another filesystem)");
331
		    conn_reply_single(scandata->conn, path, "Excluded (another filesystem)");
(-)b/clamd/session.c (-2 / +2 lines)
 Lines 236-242   int command(client_conn_t *conn, int *virus) Link Here 
236
	    int multiscan, max, alive;
236
	    int multiscan, max, alive;
237
237
238
	    /* use MULTISCAN only for directories (bb #1869) */
238
	    /* use MULTISCAN only for directories (bb #1869) */
239
	    if (STAT(conn->filename, &sb) == 0 &&
239
	    if (CLAMSTAT(conn->filename, &sb) == 0 &&
240
		!S_ISDIR(sb.st_mode)) {
240
		!S_ISDIR(sb.st_mode)) {
241
		thrmgr_setactivetask(NULL, "CONTSCAN");
241
		thrmgr_setactivetask(NULL, "CONTSCAN");
242
		type = TYPE_CONTSCAN;
242
		type = TYPE_CONTSCAN;
 Lines 384-390   int command(client_conn_t *conn, int *virus) Link Here 
384
	 flags |= CLI_FTW_FOLLOW_FILE_SYMLINK;
384
	 flags |= CLI_FTW_FOLLOW_FILE_SYMLINK;
385
385
386
     if(!optget(opts, "CrossFilesystems")->enabled)
386
     if(!optget(opts, "CrossFilesystems")->enabled)
387
	 if(STAT(conn->filename, &sb) == 0)
387
	 if(CLAMSTAT(conn->filename, &sb) == 0)
388
	     scandata.dev = sb.st_dev;
388
	     scandata.dev = sb.st_dev;
389
389
390
     ret = cli_ftw(conn->filename, flags,  maxdirrec ? maxdirrec : INT_MAX, scan_callback, &data, scan_pathchk);
390
     ret = cli_ftw(conn->filename, flags,  maxdirrec ? maxdirrec : INT_MAX, scan_callback, &data, scan_pathchk);
(-)b/clamdscan/proto.c (-1 / +1 lines)
 Lines 296-302   int dsresult(int sockd, int scantype, const char *filename, int *printok, int *e Link Here 
296
	    logg("STDIN: noreply from clamd\n.");
296
	    logg("STDIN: noreply from clamd\n.");
297
	    return -1;
297
	    return -1;
298
	}
298
	}
299
        if(STAT(filename, &sb) == -1) {
299
        if(CLAMSTAT(filename, &sb) == -1) {
300
	    logg("~%s: stat() failed with %s, clamd may not be responding\n",
300
	    logg("~%s: stat() failed with %s, clamd may not be responding\n",
301
		 filename, strerror(errno));
301
		 filename, strerror(errno));
302
	    return -1;
302
	    return -1;
(-)b/clamscan/manager.c (-5 / +5 lines)
 Lines 249-255   static void scanfile(const char *filename, struct cl_engine *engine, const struc Link Here 
249
    }
249
    }
250
250
251
    /* argh, don't scan /proc files */
251
    /* argh, don't scan /proc files */
252
    if(STAT(filename, &sb) != -1) {
252
    if(CLAMSTAT(filename, &sb) != -1) {
253
#ifdef C_LINUX
253
#ifdef C_LINUX
254
	if(procdev && sb.st_dev == procdev) {
254
	if(procdev && sb.st_dev == procdev) {
255
	    if(!printinfected)
255
	    if(!printinfected)
 Lines 412-418   static void scandirs(const char *dirname, struct cl_engine *engine, const struct Link Here 
412
			    if(dirlnk != 2 && filelnk != 2) {
412
			    if(dirlnk != 2 && filelnk != 2) {
413
				if(!printinfected)
413
				if(!printinfected)
414
				    logg("%s: Symbolic link\n", fname);
414
				    logg("%s: Symbolic link\n", fname);
415
			    } else if(STAT(fname, &sb) != -1) {
415
			    } else if(CLAMSTAT(fname, &sb) != -1) {
416
				if(S_ISREG(sb.st_mode) && filelnk == 2) {
416
				if(S_ISREG(sb.st_mode) && filelnk == 2) {
417
				    scanfile(fname, engine, opts, options);
417
				    scanfile(fname, engine, opts, options);
418
				} else if(S_ISDIR(sb.st_mode) && dirlnk == 2) {
418
				} else if(S_ISDIR(sb.st_mode) && dirlnk == 2) {
 Lines 884-890   int scanmanager(const struct optstruct *opts) Link Here 
884
884
885
#ifdef C_LINUX
885
#ifdef C_LINUX
886
    procdev = (dev_t) 0;
886
    procdev = (dev_t) 0;
887
    if(STAT("/proc", &sb) != -1 && !sb.st_size)
887
    if(CLAMSTAT("/proc", &sb) != -1 && !sb.st_size)
888
	procdev = sb.st_dev;
888
	procdev = sb.st_dev;
889
#endif
889
#endif
890
890
 Lines 895-901   int scanmanager(const struct optstruct *opts) Link Here 
895
	    logg("!Can't get absolute pathname of current working directory\n");
895
	    logg("!Can't get absolute pathname of current working directory\n");
896
	    ret = 2;
896
	    ret = 2;
897
	} else {
897
	} else {
898
	    STAT(cwd, &sb);
898
	    CLAMSTAT(cwd, &sb);
899
	    scandirs(cwd, engine, opts, options, 1, sb.st_dev);
899
	    scandirs(cwd, engine, opts, options, 1, sb.st_dev);
900
	}
900
	}
901
901
 Lines 923-929   int scanmanager(const struct optstruct *opts) Link Here 
923
		    if(dirlnk == 0 && filelnk == 0) {
923
		    if(dirlnk == 0 && filelnk == 0) {
924
			if(!printinfected)
924
			if(!printinfected)
925
			    logg("%s: Symbolic link\n", file);
925
			    logg("%s: Symbolic link\n", file);
926
		    } else if(STAT(file, &sb) != -1) {
926
		    } else if(CLAMSTAT(file, &sb) != -1) {
927
			if(S_ISREG(sb.st_mode) && filelnk) {
927
			if(S_ISREG(sb.st_mode) && filelnk) {
928
			    scanfile(file, engine, opts, options);
928
			    scanfile(file, engine, opts, options);
929
			} else if(S_ISDIR(sb.st_mode) && dirlnk) {
929
			} else if(S_ISDIR(sb.st_mode) && dirlnk) {
(-)b/freshclam/freshclam.c (-1 / +1 lines)
 Lines 333-339   main (int argc, char **argv) Link Here 
333
333
334
    if (optget (opts, "HTTPProxyPassword")->enabled)
334
    if (optget (opts, "HTTPProxyPassword")->enabled)
335
    {
335
    {
336
        if (STAT (cfgfile, &statbuf) == -1)
336
        if (CLAMSTAT (cfgfile, &statbuf) == -1)
337
        {
337
        {
338
            logg ("^Can't stat %s (critical error)\n", cfgfile);
338
            logg ("^Can't stat %s (critical error)\n", cfgfile);
339
            optfree (opts);
339
            optfree (opts);
(-)b/freshclam/manager.c (-1 / +1 lines)
 Lines 2621-2627   updatecustomdb (const char *url, int *signo, const struct optstruct *opts, Link Here 
2621
        rtimeout = optget (opts, "ReceiveTimeout")->numarg;
2621
        rtimeout = optget (opts, "ReceiveTimeout")->numarg;
2622
2622
2623
        *mtime = 0;
2623
        *mtime = 0;
2624
        if (STAT (dbname, &sb) != -1)
2624
        if (CLAMSTAT (dbname, &sb) != -1)
2625
            Rfc2822DateTime (mtime, sb.st_mtime);
2625
            Rfc2822DateTime (mtime, sb.st_mtime);
2626
2626
2627
        newfile = cli_gentemp (updtmpdir);
2627
        newfile = cli_gentemp (updtmpdir);
(-)b/libclamav/clamav.h (-2 / +2 lines)
 Lines 29-42    Link Here 
29
#include <unistd.h>
29
#include <unistd.h>
30
30
31
#define STATBUF struct stat64
31
#define STATBUF struct stat64
32
#define STAT stat64
32
#define CLAMSTAT stat64
33
#define LSTAT lstat64
33
#define LSTAT lstat64
34
#define FSTAT fstat64
34
#define FSTAT fstat64
35
#define safe_open(a, b) open(a, b|O_LARGEFILE)
35
#define safe_open(a, b) open(a, b|O_LARGEFILE)
36
#else
36
#else
37
37
38
#define STATBUF struct stat
38
#define STATBUF struct stat
39
#define STAT stat
39
#define CLAMSTAT stat
40
#define LSTAT lstat
40
#define LSTAT lstat
41
#define FSTAT fstat
41
#define FSTAT fstat
42
/* Nothing is safe in windows, not even open, safe_open defined under /win32 */
42
/* Nothing is safe in windows, not even open, safe_open defined under /win32 */
(-)b/libclamav/mbox.c (-1 / +1 lines)
 Lines 2813-2819   rfc1341(message *m, const char *dir) Link Here 
2813
	} else if(errno == EEXIST) {
2813
	} else if(errno == EEXIST) {
2814
		STATBUF statb;
2814
		STATBUF statb;
2815
2815
2816
		if(STAT(pdir, &statb) < 0) {
2816
		if(CLAMSTAT(pdir, &statb) < 0) {
2817
			char err[128];
2817
			char err[128];
2818
			cli_errmsg("Partial directory %s: %s\n", pdir,
2818
			cli_errmsg("Partial directory %s: %s\n", pdir,
2819
				cli_strerror(errno, err, sizeof(err)));
2819
				cli_strerror(errno, err, sizeof(err)));
(-)b/libclamav/others.c (-2 / +2 lines)
 Lines 903-909   cli_rmdirs(const char *name) Link Here 
903
	char err[128];
903
	char err[128];
904
904
905
905
906
    if(STAT(name, &statb) < 0) {
906
    if(CLAMSTAT(name, &statb) < 0) {
907
	cli_warnmsg("cli_rmdirs: Can't locate %s: %s\n", name, cli_strerror(errno, err, sizeof(err)));
907
	cli_warnmsg("cli_rmdirs: Can't locate %s: %s\n", name, cli_strerror(errno, err, sizeof(err)));
908
	return -1;
908
	return -1;
909
    }
909
    }
 Lines 974-980   int cli_rmdirs(const char *dirname) Link Here 
974
974
975
    chmod(dirname, 0700);
975
    chmod(dirname, 0700);
976
    if((dd = opendir(dirname)) != NULL) {
976
    if((dd = opendir(dirname)) != NULL) {
977
	while(STAT(dirname, &maind) != -1) {
977
	while(CLAMSTAT(dirname, &maind) != -1) {
978
	    if(!rmdir(dirname)) break;
978
	    if(!rmdir(dirname)) break;
979
	    if(errno != ENOTEMPTY && errno != EEXIST && errno != EBADF) {
979
	    if(errno != ENOTEMPTY && errno != EEXIST && errno != EBADF) {
980
		cli_errmsg("cli_rmdirs: Can't remove temporary directory %s: %s\n", dirname, cli_strerror(errno, err, sizeof(err)));
980
		cli_errmsg("cli_rmdirs: Can't remove temporary directory %s: %s\n", dirname, cli_strerror(errno, err, sizeof(err)));
(-)b/libclamav/others_common.c (-1 / +1 lines)
 Lines 520-526   static int get_filetype(const char *fname, int flags, int need_stat, Link Here 
520
    }
520
    }
521
521
522
    if (need_stat) {
522
    if (need_stat) {
523
	if (STAT(fname, statbuf) == -1)
523
	if (CLAMSTAT(fname, statbuf) == -1)
524
	    return -1;
524
	    return -1;
525
	stated = 1;
525
	stated = 1;
526
    }
526
    }
(-)b/libclamav/readdb.c (-4 / +4 lines)
 Lines 2901-2907   int cl_load(const char *path, struct cl_engine *engine, unsigned int *signo, uns Link Here 
2901
	return CL_EARG;
2901
	return CL_EARG;
2902
    }
2902
    }
2903
2903
2904
    if(STAT(path, &sb) == -1) {
2904
    if(CLAMSTAT(path, &sb) == -1) {
2905
        cli_errmsg("cl_load(): Can't get status of %s\n", path);
2905
        cli_errmsg("cl_load(): Can't get status of %s\n", path);
2906
        return CL_ESTAT;
2906
        return CL_ESTAT;
2907
    }
2907
    }
 Lines 3021-3027   int cl_statinidir(const char *dirname, struct cl_stat *dbstat) Link Here 
3021
3021
3022
		strcpy(dbstat->statdname[dbstat->entries - 1], dent->d_name);
3022
		strcpy(dbstat->statdname[dbstat->entries - 1], dent->d_name);
3023
#endif
3023
#endif
3024
		STAT(fname, &dbstat->stattab[dbstat->entries - 1]);
3024
		CLAMSTAT(fname, &dbstat->stattab[dbstat->entries - 1]);
3025
		free(fname);
3025
		free(fname);
3026
	    }
3026
	    }
3027
	}
3027
	}
 Lines 3076-3082   int cl_statchkdir(const struct cl_stat *dbstat) Link Here 
3076
		}
3076
		}
3077
3077
3078
		sprintf(fname, "%s"PATHSEP"%s", dbstat->dir, dent->d_name);
3078
		sprintf(fname, "%s"PATHSEP"%s", dbstat->dir, dent->d_name);
3079
		STAT(fname, &sb);
3079
		CLAMSTAT(fname, &sb);
3080
		free(fname);
3080
		free(fname);
3081
3081
3082
		found = 0;
3082
		found = 0;
 Lines 3426-3432   int cl_countsigs(const char *path, unsigned int countoptions, unsigned int *sigs Link Here 
3426
    if(!sigs)
3426
    if(!sigs)
3427
	return CL_ENULLARG;
3427
	return CL_ENULLARG;
3428
3428
3429
    if(STAT(path, &sb) == -1) {
3429
    if(CLAMSTAT(path, &sb) == -1) {
3430
	cli_errmsg("cl_countsigs: Can't stat %s\n", path);
3430
	cli_errmsg("cl_countsigs: Can't stat %s\n", path);
3431
	return CL_ESTAT;
3431
	return CL_ESTAT;
3432
    }
3432
    }
(-)b/shared/actions.c (-1 / +1 lines)
 Lines 123-129   static void action_remove(const char *filename) { Link Here 
123
123
124
static int isdir(void) {
124
static int isdir(void) {
125
    STATBUF sb;
125
    STATBUF sb;
126
    if(STAT(actarget, &sb) || !S_ISDIR(sb.st_mode)) {
126
    if(CLAMSTAT(actarget, &sb) || !S_ISDIR(sb.st_mode)) {
127
	logg("!'%s' doesn't exist or is not a directory\n", actarget);
127
	logg("!'%s' doesn't exist or is not a directory\n", actarget);
128
	return 0;
128
	return 0;
129
    }
129
    }
(-)b/shared/output.c (-1 / +1 lines)
 Lines 261-267   static int logg_open(void) Link Here 
261
261
262
    if(logg_file)
262
    if(logg_file)
263
        if(logg_size > 0)
263
        if(logg_size > 0)
264
            if(STAT(logg_file, &sb) != -1)
264
            if(CLAMSTAT(logg_file, &sb) != -1)
265
                if(sb.st_size > logg_size)
265
                if(sb.st_size > logg_size)
266
	                if (rename_logg(&sb))
266
	                if (rename_logg(&sb))
267
                        return -1;
267
                        return -1;
(-)b/sigtool/sigtool.c (-6 / +6 lines)
 Lines 172-178   static int hashsig(const struct optstruct *opts, unsigned int mdb, int type) Link Here 
172
172
173
    if(opts->filename) {
173
    if(opts->filename) {
174
	for(i = 0; opts->filename[i]; i++) {
174
	for(i = 0; opts->filename[i]; i++) {
175
	    if(STAT(opts->filename[i], &sb) == -1) {
175
	    if(CLAMSTAT(opts->filename[i], &sb) == -1) {
176
		mprintf("!hashsig: Can't access file %s\n", opts->filename[i]);
176
		mprintf("!hashsig: Can't access file %s\n", opts->filename[i]);
177
		perror("hashsig");
177
		perror("hashsig");
178
		return -1;
178
		return -1;
 Lines 523-529   static int script2cdiff(const char *script, const char *builder, const struct op Link Here 
523
	int bytes;
523
	int bytes;
524
524
525
525
526
    if(STAT(script, &sb) == -1) {
526
    if(CLAMSTAT(script, &sb) == -1) {
527
	mprintf("!script2diff: Can't stat file %s\n", script);
527
	mprintf("!script2diff: Can't stat file %s\n", script);
528
	return -1;
528
	return -1;
529
    }
529
    }
 Lines 669-675   static int build(const struct optstruct *opts) Link Here 
669
    if(optget(opts, "datadir")->active)
669
    if(optget(opts, "datadir")->active)
670
	localdbdir = optget(opts, "datadir")->strarg;
670
	localdbdir = optget(opts, "datadir")->strarg;
671
671
672
    if(STAT("COPYING", &foo) == -1) {
672
    if(CLAMSTAT("COPYING", &foo) == -1) {
673
	mprintf("!build: COPYING file not found in current working directory.\n");
673
	mprintf("!build: COPYING file not found in current working directory.\n");
674
	return -1;
674
	return -1;
675
    }
675
    }
 Lines 1444-1450   static int listsigs(const struct optstruct *opts, int mode) Link Here 
1444
	name = optget(opts, "list-sigs")->strarg;
1444
	name = optget(opts, "list-sigs")->strarg;
1445
	if(access(name, R_OK) && localdbdir)
1445
	if(access(name, R_OK) && localdbdir)
1446
	    name = localdbdir;
1446
	    name = localdbdir;
1447
	if(STAT(name, &sb) == -1) {
1447
	if(CLAMSTAT(name, &sb) == -1) {
1448
	    mprintf("--list-sigs: Can't get status of %s\n", name);
1448
	    mprintf("--list-sigs: Can't get status of %s\n", name);
1449
	    return -1;
1449
	    return -1;
1450
	}
1450
	}
 Lines 1837-1843   static int dircopy(const char *src, const char *dest) Link Here 
1837
	char spath[512], dpath[512];
1837
	char spath[512], dpath[512];
1838
1838
1839
1839
1840
    if(STAT(dest, &sb) == -1) {
1840
    if(CLAMSTAT(dest, &sb) == -1) {
1841
	if(mkdir(dest, 0755)) {
1841
	if(mkdir(dest, 0755)) {
1842
	    /* mprintf("!dircopy: Can't create temporary directory %s\n", dest); */
1842
	    /* mprintf("!dircopy: Can't create temporary directory %s\n", dest); */
1843
	    return -1;
1843
	    return -1;
 Lines 3039-3045   int main(int argc, char **argv) Link Here 
3039
	    mprintf("!--verify-cdiff requires two arguments\n");
3039
	    mprintf("!--verify-cdiff requires two arguments\n");
3040
	    ret = -1;
3040
	    ret = -1;
3041
	} else {
3041
	} else {
3042
	    if(STAT(opts->filename[0], &sb) == -1) {
3042
	    if(CLAMSTAT(opts->filename[0], &sb) == -1) {
3043
		mprintf("--verify-cdiff: Can't get status of %s\n", opts->filename[0]);
3043
		mprintf("--verify-cdiff: Can't get status of %s\n", opts->filename[0]);
3044
		ret = -1;
3044
		ret = -1;
3045
	    } else {
3045
	    } else {
(-)b/unit_tests/check_clamd.c (-1 / +1 lines)
 Lines 350-356   static size_t prepare_instream(char *buf, size_t off, size_t buflen) Link Here 
350
    STATBUF stbuf;
350
    STATBUF stbuf;
351
    int fd, nread;
351
    int fd, nread;
352
    uint32_t chunk;
352
    uint32_t chunk;
353
    fail_unless_fmt(STAT(SCANFILE, &stbuf) != -1, "stat failed for %s: %s", SCANFILE, strerror(errno));
353
    fail_unless_fmt(CLAMSTAT(SCANFILE, &stbuf) != -1, "stat failed for %s: %s", SCANFILE, strerror(errno));
354
354
355
    fd = open(SCANFILE, O_RDONLY);
355
    fd = open(SCANFILE, O_RDONLY);
356
    fail_unless_fmt(fd != -1, "open failed: %s\n", strerror(errno));
356
    fail_unless_fmt(fd != -1, "open failed: %s\n", strerror(errno));

Return to bug 8993