... | ... |
@@ -162,7 +162,7 @@ int main(int argc, char **argv) { |
162 | 162 |
|
163 | 163 |
if((opt = optget(opts, "LogFile"))->enabled) { |
164 | 164 |
logg_file = opt->strarg; |
165 |
- if(strlen(logg_file) < 2 || logg_file[0] != '/') { |
|
165 |
+ if(!cli_is_abspath(logg_file)) { |
|
166 | 166 |
fprintf(stderr, "ERROR: LogFile requires full path.\n"); |
167 | 167 |
logg_close(); |
168 | 168 |
optfree(opts); |
... | ... |
@@ -59,7 +59,7 @@ static int cpool_addunix(char *path) { |
59 | 59 |
struct sockaddr_un *srv; |
60 | 60 |
struct CP_ENTRY *cpe = &cp->pool[cp->entries-1]; |
61 | 61 |
|
62 |
- if(strlen(path)<2 || *path!='/') { |
|
62 |
+ if(!cli_is_abspath(path)) { |
|
63 | 63 |
logg("!Unix clamd socket must be an absolute path\n"); |
64 | 64 |
return 1; |
65 | 65 |
} |
... | ... |
@@ -237,7 +237,7 @@ int main(int argc, char **argv) |
237 | 237 |
dir = optget(opts, "config-dir")->strarg; |
238 | 238 |
printf("Checking configuration files in %s\n", dir); |
239 | 239 |
for(i = 0; cfgfile[i].name; i++) { |
240 |
- snprintf(path, sizeof(path), "%s/%s", dir, cfgfile[i].name); |
|
240 |
+ snprintf(path, sizeof(path), "%s"PATHSEP"%s", dir, cfgfile[i].name); |
|
241 | 241 |
path[511] = 0; |
242 | 242 |
if(access(path, R_OK)) { |
243 | 243 |
printf("\n%s not found\n", cfgfile[i].name); |
... | ... |
@@ -304,7 +304,7 @@ int main(int argc, char **argv) |
304 | 304 |
printf("Database directory: %s\n", dbdir); |
305 | 305 |
flevel = cl_retflevel(); |
306 | 306 |
for(i = 0; dbnames[i]; i++) { |
307 |
- snprintf(path, sizeof(path), "%s/%s", dbdir, dbnames[i]); |
|
307 |
+ snprintf(path, sizeof(path), "%s"PATHSEP"%s", dbdir, dbnames[i]); |
|
308 | 308 |
path[511] = 0; |
309 | 309 |
if(!access(path, R_OK)) { |
310 | 310 |
cvd = cl_cvdhead(path); |
... | ... |
@@ -210,7 +210,7 @@ int main(int argc, char **argv) |
210 | 210 |
if((opt = optget(opts, "LogFile"))->enabled) { |
211 | 211 |
char timestr[32]; |
212 | 212 |
logg_file = opt->strarg; |
213 |
- if(strlen(logg_file) < 2 || (logg_file[0] != '/' && logg_file[0] != '\\' && logg_file[1] != ':')) { |
|
213 |
+ if(!cli_is_abspath(logg_file)) { |
|
214 | 214 |
fprintf(stderr, "ERROR: LogFile requires full path.\n"); |
215 | 215 |
ret = 1; |
216 | 216 |
break; |
... | ... |
@@ -130,14 +130,14 @@ static char *makeabs(const char *basepath) { |
130 | 130 |
logg("^Can't make room for fullpath.\n"); |
131 | 131 |
return NULL; |
132 | 132 |
} |
133 |
- if(*basepath != '/') { /* FIXME: to be unified */ |
|
133 |
+ if(!cli_is_abspath(basepath)) { |
|
134 | 134 |
if(!getcwd(ret, PATH_MAX)) { |
135 | 135 |
logg("^Can't get absolute pathname of current working directory.\n"); |
136 | 136 |
free(ret); |
137 | 137 |
return NULL; |
138 | 138 |
} |
139 | 139 |
namelen = strlen(ret); |
140 |
- snprintf(&ret[namelen], PATH_MAX - namelen, "/%s", basepath); |
|
140 |
+ snprintf(&ret[namelen], PATH_MAX - namelen, PATHSEP"%s", basepath); |
|
141 | 141 |
} else { |
142 | 142 |
strncpy(ret, basepath, PATH_MAX); |
143 | 143 |
} |
... | ... |
@@ -510,7 +510,7 @@ static int make_connection_real(const char *soname, conn_t *conn) |
510 | 510 |
#ifdef _WIN32 |
511 | 511 |
{ |
512 | 512 |
#else |
513 |
- if(soname[0] == '/' || (access(soname, F_OK) == 0)) { |
|
513 |
+ if(cli_is_abspath(soname) || (access(soname, F_OK) == 0)) { |
|
514 | 514 |
struct sockaddr_un addr; |
515 | 515 |
s = socket(AF_UNIX, SOCK_STREAM, 0); |
516 | 516 |
if(s < 0) { |
... | ... |
@@ -210,10 +210,10 @@ static int scandirs(const char *dirname, struct cl_engine *engine, const struct |
210 | 210 |
if(strcmp(dent->d_name, ".") && strcmp(dent->d_name, "..")) { |
211 | 211 |
/* build the full name */ |
212 | 212 |
fname = malloc(strlen(dirname) + strlen(dent->d_name) + 2); |
213 |
- if(!strcmp(dirname, "/")) |
|
214 |
- sprintf(fname, "/%s", dent->d_name); |
|
213 |
+ if(!strcmp(dirname, PATHSEP)) |
|
214 |
+ sprintf(fname, PATHSEP"%s", dent->d_name); |
|
215 | 215 |
else |
216 |
- sprintf(fname, "%s/%s", dirname, dent->d_name); |
|
216 |
+ sprintf(fname, "%s"PATHSEP"%s", dirname, dent->d_name); |
|
217 | 217 |
|
218 | 218 |
/* stat the file */ |
219 | 219 |
if(lstat(fname, &statbuf) != -1) { |
... | ... |
@@ -597,7 +597,7 @@ int scanmanager(const struct optstruct *opts) |
597 | 597 |
ret = 56; |
598 | 598 |
} else { |
599 | 599 |
for(i = strlen(file) - 1; i > 0; i--) { |
600 |
- if(file[i] == '/') |
|
600 |
+ if(file[i] == *PATHSEP) |
|
601 | 601 |
file[i] = 0; |
602 | 602 |
else |
603 | 603 |
break; |
... | ... |
@@ -349,7 +349,7 @@ static int ea05(int desc, cli_ctx *ctx, char *tmpd) { |
349 | 349 |
/* FIXME: REGRESSION NEEDED! */ |
350 | 350 |
/* UNP.usize = u2a(UNP.outputbuf, UNP.usize); */ |
351 | 351 |
|
352 |
- snprintf(tempfile, 1023, "%s/autoit.%.3u", tmpd, files); |
|
352 |
+ snprintf(tempfile, 1023, "%s"PATHSEP"autoit.%.3u", tmpd, files); |
|
353 | 353 |
tempfile[1023]='\0'; |
354 | 354 |
if((i = open(tempfile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU)) < 0) { |
355 | 355 |
cli_dbgmsg("autoit: Can't create file %s\n", tempfile); |
... | ... |
@@ -859,7 +859,7 @@ static int ea06(int desc, cli_ctx *ctx, char *tmpd) { |
859 | 859 |
UNP.cur_output = UNP.usize ; |
860 | 860 |
} |
861 | 861 |
|
862 |
- snprintf(tempfile, 1023, "%s/autoit.%.3u", tmpd, files); |
|
862 |
+ snprintf(tempfile, 1023, "%s"PATHSEP"autoit.%.3u", tmpd, files); |
|
863 | 863 |
tempfile[1023]='\0'; |
864 | 864 |
if((i = open(tempfile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU)) < 0) { |
865 | 865 |
cli_dbgmsg("autoit: Can't create file %s\n", tempfile); |
... | ... |
@@ -666,21 +666,9 @@ fileblobInfected(const fileblob *fb) |
666 | 666 |
void |
667 | 667 |
sanitiseName(char *name) |
668 | 668 |
{ |
669 |
- while(*name) { |
|
670 |
-#ifdef C_DARWIN |
|
671 |
- *name &= '\177'; |
|
672 |
-#endif |
|
673 |
-#if defined(MSDOS) || defined(C_OS2) |
|
674 |
- /* |
|
675 |
- * Don't take it from this that ClamAV supports DOS, it doesn't |
|
676 |
- * I don't know if spaces are legal in OS/2. |
|
677 |
- */ |
|
678 |
- if(strchr("%/*?<>|\\\"+=,;:\t ~", *name)) |
|
679 |
-#elif defined(_WIN32) |
|
680 |
- if(strchr("%/*?<>|\\\"+=,;:\t~", *name)) |
|
681 |
-#else |
|
682 |
- if(*name == '/') |
|
683 |
-#endif |
|
669 |
+ char c; |
|
670 |
+ while((c = *name)) { |
|
671 |
+ if(c!='.' && c!='_' && (c>'z' || c<'0' || (c>'9' && c<'A') || (c>'Z' && c<'a'))) |
|
684 | 672 |
*name = '_'; |
685 | 673 |
name++; |
686 | 674 |
} |
... | ... |
@@ -689,7 +689,7 @@ static int chm_decompress_stream(int fd, chm_metadata_t *metadata, const char *d |
689 | 689 |
char filename[1024]; |
690 | 690 |
struct cab_file file; |
691 | 691 |
|
692 |
- snprintf(filename, 1024, "%s/clamav-unchm.bin", dirname); |
|
692 |
+ snprintf(filename, 1024, "%s"PATHSEP"clamav-unchm.bin", dirname); |
|
693 | 693 |
tmpfd = open(filename, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU); |
694 | 694 |
if (tmpfd<0) { |
695 | 695 |
cli_dbgmsg("open failed for %s\n", filename); |
... | ... |
@@ -822,7 +822,7 @@ int cli_chm_extract_file(int fd, char *dirname, chm_metadata_t *metadata, cli_ct |
822 | 822 |
cli_dbgmsg("seek in uncompressed stream failed\n"); |
823 | 823 |
return CL_EFORMAT; |
824 | 824 |
} |
825 |
- snprintf(filename, 1024, "%s/%lu.chm", dirname, (unsigned long int) metadata->file_offset); |
|
825 |
+ snprintf(filename, 1024, "%s"PATHSEP"%lu.chm", dirname, (unsigned long int) metadata->file_offset); |
|
826 | 826 |
metadata->ofd = open(filename, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU); |
827 | 827 |
if (metadata->ofd < 0) { |
828 | 828 |
return CL_ECREAT; |
... | ... |
@@ -105,7 +105,7 @@ static int cli_untgz(int fd, const char *destdir) |
105 | 105 |
return -1; |
106 | 106 |
} |
107 | 107 |
|
108 |
- snprintf(path, pathlen, "%s/%s", destdir, name); |
|
108 |
+ snprintf(path, pathlen, "%s"PATHSEP"%s", destdir, name); |
|
109 | 109 |
cli_dbgmsg("cli_untgz: Unpacking %s\n", path); |
110 | 110 |
type = block[156]; |
111 | 111 |
|
... | ... |
@@ -653,7 +653,7 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag |
653 | 653 |
tag_args.value = NULL; |
654 | 654 |
tag_args.contents = NULL; |
655 | 655 |
if (dirname) { |
656 |
- snprintf(filename, 1024, "%s/rfc2397", dirname); |
|
656 |
+ snprintf(filename, 1024, "%s"PATHSEP"rfc2397", dirname); |
|
657 | 657 |
if (mkdir(filename, 0700) && errno != EEXIST) { |
658 | 658 |
file_buff_o2 = file_buff_text = NULL; |
659 | 659 |
goto abort; |
... | ... |
@@ -666,7 +666,7 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag |
666 | 666 |
} |
667 | 667 |
|
668 | 668 |
/* this will still contains scripts that are inside comments */ |
669 |
- snprintf(filename, 1024, "%s/nocomment.html", dirname); |
|
669 |
+ snprintf(filename, 1024, "%s"PATHSEP"nocomment.html", dirname); |
|
670 | 670 |
file_buff_o2->fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IRUSR); |
671 | 671 |
if (file_buff_o2->fd == -1) { |
672 | 672 |
cli_dbgmsg("open failed: %s\n", filename); |
... | ... |
@@ -683,7 +683,7 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag |
683 | 683 |
goto abort; |
684 | 684 |
} |
685 | 685 |
|
686 |
- snprintf(filename, 1024, "%s/notags.html", dirname); |
|
686 |
+ snprintf(filename, 1024, "%s"PATHSEP"notags.html", dirname); |
|
687 | 687 |
file_buff_text->fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IRUSR); |
688 | 688 |
if(file_buff_text->fd == -1) { |
689 | 689 |
cli_dbgmsg("open failed: %s\n", filename); |
... | ... |
@@ -1482,7 +1482,7 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag |
1482 | 1482 |
if (!file_tmp_o1) { |
1483 | 1483 |
goto abort; |
1484 | 1484 |
} |
1485 |
- snprintf(filename, 1024, "%s/rfc2397", dirname); |
|
1485 |
+ snprintf(filename, 1024, "%s"PATHSEP"rfc2397", dirname); |
|
1486 | 1486 |
tmp_file = cli_gentemp(filename); |
1487 | 1487 |
if(!tmp_file) { |
1488 | 1488 |
goto abort; |
... | ... |
@@ -1755,7 +1755,7 @@ int html_screnc_decode(int fd, const char *dirname) |
1755 | 1755 |
return FALSE; |
1756 | 1756 |
} |
1757 | 1757 |
|
1758 |
- snprintf((char*)filename, 1024, "%s/screnc.html", dirname); |
|
1758 |
+ snprintf((char*)filename, 1024, "%s"PATHSEP"screnc.html", dirname); |
|
1759 | 1759 |
ofd = open((const char*)filename, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IRUSR); |
1760 | 1760 |
|
1761 | 1761 |
if (ofd < 0) { |
... | ... |
@@ -897,7 +897,7 @@ void cli_js_output(struct parser_state *state, const char *tempdir) |
897 | 897 |
char lastchar = '\0'; |
898 | 898 |
char filename[1024]; |
899 | 899 |
|
900 |
- snprintf(filename, 1024, "%s/javascript", tempdir); |
|
900 |
+ snprintf(filename, 1024, "%s"PATHSEP"javascript", tempdir); |
|
901 | 901 |
|
902 | 902 |
buf.pos = 0; |
903 | 903 |
buf.outfd = open(filename, O_CREAT | O_WRONLY, 0600); |
... | ... |
@@ -3653,7 +3653,7 @@ rfc1341(message *m, const char *dir) |
3653 | 3653 |
|
3654 | 3654 |
tmpdir = cli_gettmpdir(); |
3655 | 3655 |
|
3656 |
- snprintf(pdir, sizeof(pdir) - 1, "%s/clamav-partial", tmpdir); |
|
3656 |
+ snprintf(pdir, sizeof(pdir) - 1, "%s"PATHSEP"clamav-partial", tmpdir); |
|
3657 | 3657 |
|
3658 | 3658 |
if((mkdir(pdir, S_IRWXU) < 0) && (errno != EEXIST)) { |
3659 | 3659 |
cli_errmsg("Can't create the directory '%s'\n", pdir); |
... | ... |
@@ -3737,7 +3737,7 @@ rfc1341(message *m, const char *dir) |
3737 | 3737 |
|
3738 | 3738 |
sanitiseName(id); |
3739 | 3739 |
|
3740 |
- snprintf(outname, sizeof(outname) - 1, "%s/%s", dir, id); |
|
3740 |
+ snprintf(outname, sizeof(outname) - 1, "%s"PATHSEP"%s", dir, id); |
|
3741 | 3741 |
|
3742 | 3742 |
cli_dbgmsg("outname: %s\n", outname); |
3743 | 3743 |
|
... | ... |
@@ -3784,7 +3784,7 @@ rfc1341(message *m, const char *dir) |
3784 | 3784 |
!strcmp("..", dent->d_name)) |
3785 | 3785 |
continue; |
3786 | 3786 |
snprintf(fullname, sizeof(fullname) - 1, |
3787 |
- "%s/%s", pdir, dent->d_name); |
|
3787 |
+ "%s"PATHSEP"%s", pdir, dent->d_name); |
|
3788 | 3788 |
dentry_idpart = strchr(dent->d_name, '_'); |
3789 | 3789 |
|
3790 | 3790 |
if(!dentry_idpart || |
... | ... |
@@ -1711,7 +1711,7 @@ int messageSavePartial(message *m, const char *dir, const char *md5id, unsigned |
1711 | 1711 |
|
1712 | 1712 |
cli_dbgmsg("messageSavePartial\n"); |
1713 | 1713 |
time_val = time(NULL); |
1714 |
- snprintf(fullname, 1024, "%s/clamav-partial-%lu_%s-%u", dir, time_val, md5id, part); |
|
1714 |
+ snprintf(fullname, 1024, "%s"PATHSEP"clamav-partial-%lu_%s-%u", dir, time_val, md5id, part); |
|
1715 | 1715 |
|
1716 | 1716 |
fb = messageExport(m, fullname, |
1717 | 1717 |
(void *(*)(void))fileblobCreate, |
... | ... |
@@ -201,9 +201,9 @@ static int nsis_unpack_next(struct nsis_st *n, cli_ctx *ctx) { |
201 | 201 |
return ret; |
202 | 202 |
|
203 | 203 |
if (n->fno) |
204 |
- snprintf(n->ofn, 1023, "%s/content.%.3u", n->dir, n->fno); |
|
204 |
+ snprintf(n->ofn, 1023, "%s"PATHSEP"content.%.3u", n->dir, n->fno); |
|
205 | 205 |
else |
206 |
- snprintf(n->ofn, 1023, "%s/headers", n->dir); |
|
206 |
+ snprintf(n->ofn, 1023, "%s"PATHSEP"headers", n->dir); |
|
207 | 207 |
|
208 | 208 |
n->fno++; |
209 | 209 |
|
... | ... |
@@ -534,7 +534,7 @@ static int ole2_walk_property_tree(int fd, ole2_header_t *hdr, const char *dir, |
534 | 534 |
if (dir) { |
535 | 535 |
dirname = (char *) cli_malloc(strlen(dir)+8); |
536 | 536 |
if (!dirname) return CL_BREAK; |
537 |
- snprintf(dirname, strlen(dir)+8, "%s/%.6d", dir, prop_index); |
|
537 |
+ snprintf(dirname, strlen(dir)+8, "%s"PATHSEP"%.6d", dir, prop_index); |
|
538 | 538 |
if (mkdir(dirname, 0700) != 0) { |
539 | 539 |
free(dirname); |
540 | 540 |
return CL_BREAK; |
... | ... |
@@ -580,7 +580,7 @@ static int handler_writefile(int fd, ole2_header_t *hdr, property_t *prop, const |
580 | 580 |
name = get_property_name2(prop->name, prop->name_size); |
581 | 581 |
if (name) cnt = uniq_add(hdr->U, name, strlen(name), &hash); |
582 | 582 |
else cnt = uniq_add(hdr->U, NULL, 0, &hash); |
583 |
- snprintf(newname, sizeof(newname), "%s/%s_%u", dir, hash, cnt); |
|
583 |
+ snprintf(newname, sizeof(newname), "%s"PATHSEP"%s_%u", dir, hash, cnt); |
|
584 | 584 |
newname[sizeof(newname)-1]='\0'; |
585 | 585 |
cli_dbgmsg("OLE2 [handler_writefile]: Dumping '%s' to '%s'\n", name ? name : "<empty>", newname); |
586 | 586 |
if (name) free(name); |
... | ... |
@@ -398,6 +398,7 @@ int cli_updatelimits(cli_ctx *, unsigned long); |
398 | 398 |
unsigned long cli_getsizelimit(cli_ctx *, unsigned long); |
399 | 399 |
int cli_matchregex(const char *str, const char *regex); |
400 | 400 |
void cli_qsort(void *basep, size_t nelems, size_t size, int (*comp)(const void *, const void *)); |
401 |
+int cli_is_abspath(const char *path); |
|
401 | 402 |
|
402 | 403 |
/* symlink behaviour */ |
403 | 404 |
#define CLI_FTW_FOLLOW_FILE_SYMLINK 0x01 |
... | ... |
@@ -364,12 +364,25 @@ int cli_filecopy(const char *src, const char *dest) |
364 | 364 |
#endif |
365 | 365 |
} |
366 | 366 |
|
367 |
-#ifndef _WIN32 |
|
368 |
-static const char tmpdir[] = "/tmp"; |
|
367 |
+#ifndef P_tmpdir |
|
368 |
+#ifdef _WIN32 |
|
369 |
+#define P_tmpdir "C:\\" |
|
370 |
+#else |
|
371 |
+#define P_tmpdir "/tmp" |
|
372 |
+#endif /* _WIN32 */ |
|
373 |
+#endif /* P_tmpdir */ |
|
374 |
+ |
|
369 | 375 |
const char *cli_gettmpdir(void) { |
376 |
+ const char *tmpdir; |
|
377 |
+ if( |
|
378 |
+#ifdef _WIN32 |
|
379 |
+ !(tmpdir = getenv("TEMP")) && !(tmpdir = getenv("TMP")) |
|
380 |
+#else |
|
381 |
+ !(tmpdir = getenv("TMPDIR")) |
|
382 |
+#endif |
|
383 |
+ ) tmpdir = P_tmpdir; |
|
370 | 384 |
return tmpdir; |
371 | 385 |
} |
372 |
-#endif /* _WIN32 */ |
|
373 | 386 |
|
374 | 387 |
struct dirent_data { |
375 | 388 |
char *filename; |
... | ... |
@@ -511,9 +524,9 @@ int cli_ftw(char *path, int flags, int maxdepth, cli_ftw_cb callback, struct cli |
511 | 511 |
char *pathend; |
512 | 512 |
/* trim slashes so that dir and dir/ behave the same when |
513 | 513 |
* they are symlinks, and we are not following symlinks */ |
514 |
- while (path[0] == '/' && path[1] == '/') path++; |
|
514 |
+ while (path[0] == *PATHSEP && path[1] == *PATHSEP) path++; |
|
515 | 515 |
pathend = path + strlen(path); |
516 |
- while (pathend > path && pathend[-1] == '/') --pathend; |
|
516 |
+ while (pathend > path && pathend[-1] == *PATHSEP) --pathend; |
|
517 | 517 |
*pathend = '\0'; |
518 | 518 |
} |
519 | 519 |
if(pathchk && pathchk(path, data) == 1) |
... | ... |
@@ -606,10 +619,10 @@ static int cli_ftw_dir(const char *dirname, int flags, int maxdepth, cli_ftw_cb |
606 | 606 |
if (ret != CL_SUCCESS) |
607 | 607 |
break; |
608 | 608 |
} |
609 |
- if(!strcmp(dirname, "/")) |
|
610 |
- sprintf(fname, "/%s", dent->d_name); |
|
609 |
+ if(!strcmp(dirname, PATHSEP)) |
|
610 |
+ sprintf(fname, PATHSEP"%s", dent->d_name); |
|
611 | 611 |
else |
612 |
- sprintf(fname, "%s/%s", dirname, dent->d_name); |
|
612 |
+ sprintf(fname, "%s"PATHSEP"%s", dirname, dent->d_name); |
|
613 | 613 |
|
614 | 614 |
if(pathchk && pathchk(fname, data) == 1) { |
615 | 615 |
free(fname); |
... | ... |
@@ -897,3 +910,13 @@ void cli_qsort(void *basep, size_t nelems, size_t size, int (*comp)(const void * |
897 | 897 |
} |
898 | 898 |
} |
899 | 899 |
} |
900 |
+ |
|
901 |
+int cli_is_abspath(const char *path) { |
|
902 |
+#ifdef _WIN32 |
|
903 |
+ int len = strlen(path); |
|
904 |
+ return (len > 2 && path[0] == '\\' && path[1] == '\\') || (len > 3 && path[1] == ':' && path[2] == '\\'); |
|
905 |
+#else |
|
906 |
+ return strlen(path) > 1 && *path == '/'; |
|
907 |
+#endif |
|
908 |
+} |
|
909 |
+ |
... | ... |
@@ -392,7 +392,7 @@ cli_pdf(const char *dir, int desc, cli_ctx *ctx, off_t offset) |
392 | 392 |
has_cr = 1; |
393 | 393 |
} else |
394 | 394 |
has_cr = 0; |
395 |
- snprintf(fullname, sizeof(fullname), "%s/pdf%02u", dir, files); |
|
395 |
+ snprintf(fullname, sizeof(fullname), "%s"PATHSEP"pdf%02u", dir, files); |
|
396 | 396 |
fout = open(fullname, O_RDWR|O_CREAT|O_EXCL|O_TRUNC|O_BINARY, 0600); |
397 | 397 |
if(fout < 0) { |
398 | 398 |
char err[128]; |
... | ... |
@@ -1547,7 +1547,7 @@ int cli_load(const char *filename, struct cl_engine *engine, unsigned int *signo |
1547 | 1547 |
return CL_EOPEN; |
1548 | 1548 |
} |
1549 | 1549 |
|
1550 |
- if((dbname = strrchr(filename, '/'))) |
|
1550 |
+ if((dbname = strrchr(filename, *PATHSEP))) |
|
1551 | 1551 |
dbname++; |
1552 | 1552 |
else |
1553 | 1553 |
dbname = filename; |
... | ... |
@@ -1668,35 +1668,35 @@ static int cli_loaddbdir(const char *dirname, struct cl_engine *engine, unsigned |
1668 | 1668 |
return CL_EMEM; |
1669 | 1669 |
|
1670 | 1670 |
/* try to load local.ign and daily.cvd/daily.ign first */ |
1671 |
- sprintf(dbfile, "%s/local.ign", dirname); |
|
1671 |
+ sprintf(dbfile, "%s"PATHSEP"local.ign", dirname); |
|
1672 | 1672 |
if(!access(dbfile, R_OK) && (ret = cli_load(dbfile, engine, signo, options, NULL))) { |
1673 | 1673 |
free(dbfile); |
1674 | 1674 |
return ret; |
1675 | 1675 |
} |
1676 | 1676 |
|
1677 |
- sprintf(dbfile, "%s/daily.cld", dirname); |
|
1677 |
+ sprintf(dbfile, "%s"PATHSEP"daily.cld", dirname); |
|
1678 | 1678 |
if(access(dbfile, R_OK)) |
1679 |
- sprintf(dbfile, "%s/daily.cvd", dirname); |
|
1679 |
+ sprintf(dbfile, "%s"PATHSEP"daily.cvd", dirname); |
|
1680 | 1680 |
if(!access(dbfile, R_OK) && (ret = cli_load(dbfile, engine, signo, options, NULL))) { |
1681 | 1681 |
free(dbfile); |
1682 | 1682 |
return ret; |
1683 | 1683 |
} |
1684 | 1684 |
|
1685 |
- sprintf(dbfile, "%s/daily.ign", dirname); |
|
1685 |
+ sprintf(dbfile, "%s"PATHSEP"daily.ign", dirname); |
|
1686 | 1686 |
if(!access(dbfile, R_OK) && (ret = cli_load(dbfile, engine, signo, options, NULL))) { |
1687 | 1687 |
free(dbfile); |
1688 | 1688 |
return ret; |
1689 | 1689 |
} |
1690 | 1690 |
|
1691 | 1691 |
/* try to load local.gdb next */ |
1692 |
- sprintf(dbfile, "%s/local.gdb", dirname); |
|
1692 |
+ sprintf(dbfile, "%s"PATHSEP"local.gdb", dirname); |
|
1693 | 1693 |
if(!access(dbfile, R_OK) && (ret = cli_load(dbfile, engine, signo, options, NULL))) { |
1694 | 1694 |
free(dbfile); |
1695 | 1695 |
return ret; |
1696 | 1696 |
} |
1697 | 1697 |
|
1698 | 1698 |
/* check for and load daily.cfg */ |
1699 |
- sprintf(dbfile, "%s/daily.cfg", dirname); |
|
1699 |
+ sprintf(dbfile, "%s"PATHSEP"daily.cfg", dirname); |
|
1700 | 1700 |
if(!access(dbfile, R_OK) && (ret = cli_load(dbfile, engine, signo, options, NULL))) { |
1701 | 1701 |
free(dbfile); |
1702 | 1702 |
return ret; |
... | ... |
@@ -1726,7 +1726,7 @@ static int cli_loaddbdir(const char *dirname, struct cl_engine *engine, unsigned |
1726 | 1726 |
closedir(dd); |
1727 | 1727 |
return CL_EMEM; |
1728 | 1728 |
} |
1729 |
- sprintf(dbfile, "%s/%s", dirname, dent->d_name); |
|
1729 |
+ sprintf(dbfile, "%s"PATHSEP"%s", dirname, dent->d_name); |
|
1730 | 1730 |
ret = cli_load(dbfile, engine, signo, options, NULL); |
1731 | 1731 |
|
1732 | 1732 |
if(ret) { |
... | ... |
@@ -1858,7 +1858,7 @@ int cl_statinidir(const char *dirname, struct cl_stat *dbstat) |
1858 | 1858 |
closedir(dd); |
1859 | 1859 |
return CL_EMEM; |
1860 | 1860 |
} |
1861 |
- sprintf(fname, "%s/%s", dirname, dent->d_name); |
|
1861 |
+ sprintf(fname, "%s"PATHSEP"%s", dirname, dent->d_name); |
|
1862 | 1862 |
#if defined(C_INTERIX) || defined(C_OS2) || defined(_WIN32) |
1863 | 1863 |
dbstat->statdname[dbstat->entries - 1] = (char *) cli_malloc(strlen(dent->d_name) + 1); |
1864 | 1864 |
if(!dbstat->statdname[dbstat->entries - 1]) { |
... | ... |
@@ -1922,7 +1922,7 @@ int cl_statchkdir(const struct cl_stat *dbstat) |
1922 | 1922 |
return CL_EMEM; |
1923 | 1923 |
} |
1924 | 1924 |
|
1925 |
- sprintf(fname, "%s/%s", dbstat->dir, dent->d_name); |
|
1925 |
+ sprintf(fname, "%s"PATHSEP"%s", dbstat->dir, dent->d_name); |
|
1926 | 1926 |
stat(fname, &sb); |
1927 | 1927 |
free(fname); |
1928 | 1928 |
|
... | ... |
@@ -136,7 +136,7 @@ static int cli_scandir(const char *dirname, cli_ctx *ctx) |
136 | 136 |
return CL_EMEM; |
137 | 137 |
} |
138 | 138 |
|
139 |
- sprintf(fname, "%s/%s", dirname, dent->d_name); |
|
139 |
+ sprintf(fname, "%s"PATHSEP"%s", dirname, dent->d_name); |
|
140 | 140 |
|
141 | 141 |
/* stat the file */ |
142 | 142 |
if(lstat(fname, &statbuf) != -1) { |
... | ... |
@@ -752,7 +752,7 @@ static int cli_vba_scandir(const char *dirname, cli_ctx *ctx, struct uniq *U) |
752 | 752 |
|
753 | 753 |
for(i = 0; i < vba_project->count; i++) { |
754 | 754 |
for(j = 0; (unsigned int)j < vba_project->colls[i]; j++) { |
755 |
- snprintf(vbaname, 1024, "%s/%s_%u", vba_project->dir, vba_project->name[i], j); |
|
755 |
+ snprintf(vbaname, 1024, "%s"PATHSEP"%s_%u", vba_project->dir, vba_project->name[i], j); |
|
756 | 756 |
vbaname[sizeof(vbaname)-1] = '\0'; |
757 | 757 |
fd = open(vbaname, O_RDONLY|O_BINARY); |
758 | 758 |
if(fd == -1) continue; |
... | ... |
@@ -786,7 +786,7 @@ static int cli_vba_scandir(const char *dirname, cli_ctx *ctx, struct uniq *U) |
786 | 786 |
|
787 | 787 |
if(ret == CL_CLEAN && (hashcnt = uniq_get(U, "powerpoint document", 19, &hash))) { |
788 | 788 |
while(hashcnt--) { |
789 |
- snprintf(vbaname, 1024, "%s/%s_%u", dirname, hash, hashcnt); |
|
789 |
+ snprintf(vbaname, 1024, "%s"PATHSEP"%s_%u", dirname, hash, hashcnt); |
|
790 | 790 |
vbaname[sizeof(vbaname)-1] = '\0'; |
791 | 791 |
fd = open(vbaname, O_RDONLY|O_BINARY); |
792 | 792 |
if (fd == -1) continue; |
... | ... |
@@ -804,7 +804,7 @@ static int cli_vba_scandir(const char *dirname, cli_ctx *ctx, struct uniq *U) |
804 | 804 |
|
805 | 805 |
if (ret == CL_CLEAN && (hashcnt = uniq_get(U, "worddocument", 12, &hash))) { |
806 | 806 |
while(hashcnt--) { |
807 |
- snprintf(vbaname, sizeof(vbaname), "%s/%s_%u", dirname, hash, hashcnt); |
|
807 |
+ snprintf(vbaname, sizeof(vbaname), "%s"PATHSEP"%s_%u", dirname, hash, hashcnt); |
|
808 | 808 |
vbaname[sizeof(vbaname)-1] = '\0'; |
809 | 809 |
fd = open(vbaname, O_RDONLY|O_BINARY); |
810 | 810 |
if (fd == -1) continue; |
... | ... |
@@ -851,7 +851,7 @@ static int cli_vba_scandir(const char *dirname, cli_ctx *ctx, struct uniq *U) |
851 | 851 |
/* Check directory for embedded OLE objects */ |
852 | 852 |
hashcnt = uniq_get(U, "_1_ole10native", 14, &hash); |
853 | 853 |
while(hashcnt--) { |
854 |
- snprintf(vbaname, sizeof(vbaname), "%s/%s_%u", dirname, hash, hashcnt); |
|
854 |
+ snprintf(vbaname, sizeof(vbaname), "%s"PATHSEP"%s_%u", dirname, hash, hashcnt); |
|
855 | 855 |
vbaname[sizeof(vbaname)-1] = '\0'; |
856 | 856 |
|
857 | 857 |
fd = open(vbaname, O_RDONLY|O_BINARY); |
... | ... |
@@ -885,7 +885,7 @@ static int cli_vba_scandir(const char *dirname, cli_ctx *ctx, struct uniq *U) |
885 | 885 |
ret = CL_EMEM; |
886 | 886 |
break; |
887 | 887 |
} |
888 |
- sprintf(fullname, "%s/%s", dirname, dent->d_name); |
|
888 |
+ sprintf(fullname, "%s"PATHSEP"%s", dirname, dent->d_name); |
|
889 | 889 |
|
890 | 890 |
/* stat the file */ |
891 | 891 |
if(lstat(fullname, &statbuf) != -1) { |
... | ... |
@@ -943,7 +943,7 @@ static int cli_scanhtml(int desc, cli_ctx *ctx) |
943 | 943 |
cli_dbgmsg("cli_scanhtml: using tempdir %s\n", tempname); |
944 | 944 |
|
945 | 945 |
html_normalise_fd(desc, tempname, NULL, ctx->dconf); |
946 |
- snprintf(fullname, 1024, "%s/nocomment.html", tempname); |
|
946 |
+ snprintf(fullname, 1024, "%s"PATHSEP"nocomment.html", tempname); |
|
947 | 947 |
fd = open(fullname, O_RDONLY|O_BINARY); |
948 | 948 |
if (fd >= 0) { |
949 | 949 |
ret = cli_scandesc(fd, ctx, CL_TYPE_HTML, 0, NULL, AC_SCAN_VIR); |
... | ... |
@@ -953,7 +953,7 @@ static int cli_scanhtml(int desc, cli_ctx *ctx) |
953 | 953 |
if(ret == CL_CLEAN && sb.st_size < 2097152) { |
954 | 954 |
/* limit to 2 MB, we're not interesting in scanning large files in notags form */ |
955 | 955 |
/* TODO: don't even create notags if file is over 2 MB */ |
956 |
- snprintf(fullname, 1024, "%s/notags.html", tempname); |
|
956 |
+ snprintf(fullname, 1024, "%s"PATHSEP"notags.html", tempname); |
|
957 | 957 |
fd = open(fullname, O_RDONLY|O_BINARY); |
958 | 958 |
if(fd >= 0) { |
959 | 959 |
ret = cli_scandesc(fd, ctx, CL_TYPE_HTML, 0, NULL, AC_SCAN_VIR); |
... | ... |
@@ -962,7 +962,7 @@ static int cli_scanhtml(int desc, cli_ctx *ctx) |
962 | 962 |
} |
963 | 963 |
|
964 | 964 |
if(ret == CL_CLEAN) { |
965 |
- snprintf(fullname, 1024, "%s/javascript", tempname); |
|
965 |
+ snprintf(fullname, 1024, "%s"PATHSEP"javascript", tempname); |
|
966 | 966 |
fd = open(fullname, O_RDONLY|O_BINARY); |
967 | 967 |
if(fd >= 0) { |
968 | 968 |
ret = cli_scandesc(fd, ctx, CL_TYPE_HTML, 0, NULL, AC_SCAN_VIR); |
... | ... |
@@ -975,7 +975,7 @@ static int cli_scanhtml(int desc, cli_ctx *ctx) |
975 | 975 |
} |
976 | 976 |
|
977 | 977 |
if (ret == CL_CLEAN) { |
978 |
- snprintf(fullname, 1024, "%s/rfc2397", tempname); |
|
978 |
+ snprintf(fullname, 1024, "%s"PATHSEP"rfc2397", tempname); |
|
979 | 979 |
ret = cli_scandir(fullname, ctx); |
980 | 980 |
} |
981 | 981 |
|
... | ... |
@@ -492,7 +492,7 @@ static int real_scansis(FILE *f, cli_ctx *ctx, const char *tmpd) { |
492 | 492 |
olen = lens[j]; |
493 | 493 |
decomp = comp; |
494 | 494 |
} |
495 |
- snprintf(ofn, 1024, "%s/sis%02d", tmpd, umped); |
|
495 |
+ snprintf(ofn, 1024, "%s"PATHSEP"sis%02d", tmpd, umped); |
|
496 | 496 |
ofn[1023]='\0'; |
497 | 497 |
if ((fd=open(ofn, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0600))==-1) { |
498 | 498 |
cli_errmsg("SIS: unable to create output file %s - aborting.", ofn); |
... | ... |
@@ -709,7 +709,7 @@ static int real_scansis9x(FILE *f, cli_ctx *ctx, const char *tmpd) { |
709 | 709 |
if(getfield(s, &field) || field!=T_COMPRESSED || getd(s, &field) || getd(s, &usize) || getd(s, &usizeh) || usizeh) break; |
710 | 710 |
s->fsize[s->level]-=12; |
711 | 711 |
cli_dbgmsg("SIS: File is%s compressed - size %x -> %x\n", (field)?"":" not", s->fsize[s->level], usize); |
712 |
- snprintf(tempf, 1024, "%s/sis9x%02d", tmpd, i++); |
|
712 |
+ snprintf(tempf, 1024, "%s"PATHSEP"sis9x%02d", tmpd, i++); |
|
713 | 713 |
tempf[1023]='\0'; |
714 | 714 |
fseek(s->f, -(long)s->sleft, SEEK_CUR); |
715 | 715 |
s->sleft = s->smax = 0; |
... | ... |
@@ -1060,7 +1060,7 @@ int cli_unarj_extract_file(int fd, const char *dirname, arj_metadata_t *metadata |
1060 | 1060 |
return CL_SUCCESS; |
1061 | 1061 |
} |
1062 | 1062 |
|
1063 |
- snprintf(filename, 1024, "%s/file.uar", dirname); |
|
1063 |
+ snprintf(filename, 1024, "%s"PATHSEP"file.uar", dirname); |
|
1064 | 1064 |
cli_dbgmsg("Filename: %s\n", filename); |
1065 | 1065 |
metadata->ofd = open(filename, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0600); |
1066 | 1066 |
if (metadata->ofd < 0) { |
... | ... |
@@ -180,7 +180,7 @@ cli_untar(const char *dir, int desc, unsigned int posix, cli_ctx *ctx) |
180 | 180 |
|
181 | 181 |
strncpy(name, block, 100); |
182 | 182 |
name[100] = '\0'; |
183 |
- snprintf(fullname, sizeof(fullname)-1, "%s/tar%02u", dir, files); |
|
183 |
+ snprintf(fullname, sizeof(fullname)-1, "%s"PATHSEP"tar%02u", dir, files); |
|
184 | 184 |
fullname[sizeof(fullname)-1] = '\0'; |
185 | 185 |
fout = open(fullname, O_RDWR|O_CREAT|O_EXCL|O_TRUNC|O_BINARY, 0600); |
186 | 186 |
|
... | ... |
@@ -78,7 +78,7 @@ static int unz(uint8_t *src, uint32_t csize, uint32_t usize, uint16_t method, ui |
78 | 78 |
unsigned int res=1, written=0; |
79 | 79 |
|
80 | 80 |
if(tmpd) { |
81 |
- snprintf(name, sizeof(name), "%s/zip.%03u", tmpd, *fu); |
|
81 |
+ snprintf(name, sizeof(name), "%s"PATHSEP"zip.%03u", tmpd, *fu); |
|
82 | 82 |
name[sizeof(name)-1]='\0'; |
83 | 83 |
} else { |
84 | 84 |
if(!(tempfile = cli_gentemp(ctx->engine->tmpdir))) return CL_EMEM; |
... | ... |
@@ -265,7 +265,7 @@ cli_vba_readdir(const char *dir, struct uniq *U, uint32_t which) |
265 | 265 |
|
266 | 266 |
if (!uniq_get(U, "_vba_project", 12, &hash)) |
267 | 267 |
return NULL; |
268 |
- snprintf(fullname, sizeof(fullname), "%s/%s_%u", dir, hash, which); |
|
268 |
+ snprintf(fullname, sizeof(fullname), "%s"PATHSEP"%s_%u", dir, hash, which); |
|
269 | 269 |
fullname[sizeof(fullname)-1] = '\0'; |
270 | 270 |
fd = open(fullname, O_RDONLY|O_BINARY); |
271 | 271 |
|
... | ... |
@@ -653,7 +653,7 @@ ppt_unlzw(const char *dir, int fd, uint32_t length) |
653 | 653 |
unsigned char inbuff[PPT_LZW_BUFFSIZE], outbuff[PPT_LZW_BUFFSIZE]; |
654 | 654 |
char fullname[NAME_MAX + 1]; |
655 | 655 |
|
656 |
- snprintf(fullname, sizeof(fullname) - 1, "%s/ppt%.8lx.doc", |
|
656 |
+ snprintf(fullname, sizeof(fullname) - 1, "%s"PATHSEP"ppt%.8lx.doc", |
|
657 | 657 |
dir, (long)lseek(fd, 0L, SEEK_CUR)); |
658 | 658 |
|
659 | 659 |
ofd = open(fullname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY|O_EXCL, |
... | ... |
@@ -274,7 +274,7 @@ int unrar_open(int fd, const char *dirname, unrar_state_t *state) |
274 | 274 |
return UNRAR_PASSWD; |
275 | 275 |
} |
276 | 276 |
|
277 |
- snprintf(filename,1024,"%s/comments", dirname); |
|
277 |
+ snprintf(filename,1024,"%s"PATHSEP"comments", dirname); |
|
278 | 278 |
if(mkdir(filename,0700)) { |
279 | 279 |
unrar_dbgmsg("UNRAR: Unable to create comment temporary directory\n"); |
280 | 280 |
free(main_hdr); |
... | ... |
@@ -320,7 +320,7 @@ int unrar_open(int fd, const char *dirname, unrar_state_t *state) |
320 | 320 |
unrar_dbgmsg("UNRAR: UnPack Size: 0x%.4x\n", comment_header->unpack_size); |
321 | 321 |
unrar_dbgmsg("UNRAR: UnPack Version: 0x%.2x\n", comment_header->unpack_ver); |
322 | 322 |
unrar_dbgmsg("UNRAR: Pack Method: 0x%.2x\n", comment_header->method); |
323 |
- snprintf(filename, 1024, "%s/main.cmt", state->comment_dir); |
|
323 |
+ snprintf(filename, 1024, "%s"PATHSEP"main.cmt", state->comment_dir); |
|
324 | 324 |
ofd = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0600); |
325 | 325 |
if(ofd < 0) { |
326 | 326 |
unrar_dbgmsg("UNRAR: ERROR: Failed to open output file\n"); |
... | ... |
@@ -418,7 +418,7 @@ int unrar_extract_next_prepare(unrar_state_t *state, const char *dirname) |
418 | 418 |
if((comment_header->unpack_ver < 15) || (comment_header->unpack_ver > 29) || (comment_header->method > 0x30)) { |
419 | 419 |
unrar_dbgmsg("UNRAR: Can't process file comment - skipping\n"); |
420 | 420 |
} else { |
421 |
- snprintf(filename, 1024, "%s/%lu.cmt", state->comment_dir, state->file_count); |
|
421 |
+ snprintf(filename, 1024, "%s"PATHSEP"%lu.cmt", state->comment_dir, state->file_count); |
|
422 | 422 |
ofd = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0600); |
423 | 423 |
if(ofd < 0) { |
424 | 424 |
free(comment_header); |
... | ... |
@@ -460,7 +460,7 @@ int unrar_extract_next(unrar_state_t *state, const char *dirname) |
460 | 460 |
unrar_dbgmsg("UNRAR: Skipping file inside multi-volume solid archive\n"); |
461 | 461 |
|
462 | 462 |
} else { |
463 |
- snprintf(state->filename, 1024, "%s/%lu.ura", dirname, state->file_count); |
|
463 |
+ snprintf(state->filename, 1024, "%s"PATHSEP"%lu.ura", dirname, state->file_count); |
|
464 | 464 |
ofd = open(state->filename, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0600); |
465 | 465 |
if(ofd < 0) { |
466 | 466 |
free(state->file_header->filename); |
... | ... |
@@ -62,7 +62,7 @@ static int getdest(const char *fullpath, char **newname) { |
62 | 62 |
free(tmps); |
63 | 63 |
return -1; |
64 | 64 |
} |
65 |
- sprintf(*newname, "%s/%s", actarget, filename); |
|
65 |
+ sprintf(*newname, "%s"PATHSEP"%s", actarget, filename); |
|
66 | 66 |
for(i=1; i<1000; i++) { |
67 | 67 |
fd = open(*newname, O_WRONLY | O_CREAT | O_EXCL, 0600); |
68 | 68 |
if(fd >= 0) { |
... | ... |
@@ -70,7 +70,7 @@ static int getdest(const char *fullpath, char **newname) { |
70 | 70 |
return fd; |
71 | 71 |
} |
72 | 72 |
if(errno != EEXIST) break; |
73 |
- sprintf(*newname, "%s/%s.%03u", actarget, filename, i); |
|
73 |
+ sprintf(*newname, "%s"PATHSEP"%s.%03u", actarget, filename, i); |
|
74 | 74 |
} |
75 | 75 |
free(tmps); |
76 | 76 |
free(*newname); |
... | ... |
@@ -76,14 +76,14 @@ char *freshdbdir(void) |
76 | 76 |
if((opt = optget(opts, "DatabaseDirectory"))->enabled) { |
77 | 77 |
if(strcmp(dbdir, opt->strarg)) { |
78 | 78 |
char *daily = (char *) malloc(strlen(opt->strarg) + strlen(dbdir) + 30); |
79 |
- sprintf(daily, "%s/daily.cvd", opt->strarg); |
|
79 |
+ sprintf(daily, "%s"PATHSEP"daily.cvd", opt->strarg); |
|
80 | 80 |
if(access(daily, R_OK)) |
81 |
- sprintf(daily, "%s/daily.cld", opt->strarg); |
|
81 |
+ sprintf(daily, "%s"PATHSEP"daily.cld", opt->strarg); |
|
82 | 82 |
|
83 | 83 |
if(!access(daily, R_OK) && (d1 = cl_cvdhead(daily))) { |
84 |
- sprintf(daily, "%s/daily.cvd", dbdir); |
|
84 |
+ sprintf(daily, "%s"PATHSEP"daily.cvd", dbdir); |
|
85 | 85 |
if(access(daily, R_OK)) |
86 |
- sprintf(daily, "%s/daily.cld", dbdir); |
|
86 |
+ sprintf(daily, "%s"PATHSEP"daily.cld", dbdir); |
|
87 | 87 |
|
88 | 88 |
if(!access(daily, R_OK) && (d2 = cl_cvdhead(daily))) { |
89 | 89 |
free(daily); |
... | ... |
@@ -133,9 +133,9 @@ void print_version(const char *dbdir) |
133 | 133 |
return; |
134 | 134 |
} |
135 | 135 |
|
136 |
- sprintf(path, "%s/daily.cvd", pt); |
|
136 |
+ sprintf(path, "%s"PATHSEP"daily.cvd", pt); |
|
137 | 137 |
if(access(path, R_OK)) |
138 |
- sprintf(path, "%s/daily.cld", pt); |
|
138 |
+ sprintf(path, "%s"PATHSEP"daily.cld", pt); |
|
139 | 139 |
|
140 | 140 |
if(!dbdir) |
141 | 141 |
free(fdbdir); |
... | ... |
@@ -281,20 +281,9 @@ int match_regex(const char *filename, const char *pattern) |
281 | 281 |
if(cli_regcomp(®, pattern, flags) != 0) |
282 | 282 |
return 2; |
283 | 283 |
|
284 |
-#if !defined(C_OS2) && !defined(C_WINDOWS) |
|
285 |
- if(pattern[strlen(pattern) - 1] == '/') { |
|
286 |
- snprintf(fname, 511, "%s/", filename); |
|
284 |
+ if(pattern[strlen(pattern) - 1] == *PATHSEP) { |
|
285 |
+ snprintf(fname, 511, "%s"PATHSEP, filename); |
|
287 | 286 |
fname[512] = 0; |
288 |
-#else |
|
289 |
- if(pattern[strlen(pattern) - 1] == '\\') { |
|
290 |
- strncpy(fname, filename, 510); |
|
291 |
- fname[509]='\0'; |
|
292 |
- len = strlen(fname); |
|
293 |
- if(fname[len - 1] != '\\') { |
|
294 |
- fname[len] = '\\'; |
|
295 |
- fname[len + 1] = 0; |
|
296 |
- } |
|
297 |
-#endif |
|
298 | 287 |
} else { |
299 | 288 |
strncpy(fname, filename, 513); |
300 | 289 |
fname[512]='\0'; |
... | ... |
@@ -617,9 +617,9 @@ static int build(const struct optstruct *opts) |
617 | 617 |
|
618 | 618 |
} else { |
619 | 619 |
pt = freshdbdir(); |
620 |
- snprintf(olddb, sizeof(olddb), "%s/%s.cvd", pt, dbname); |
|
620 |
+ snprintf(olddb, sizeof(olddb), "%s"PATHSEP"%s.cvd", pt, dbname); |
|
621 | 621 |
if(access(olddb, R_OK)) |
622 |
- snprintf(olddb, sizeof(olddb), "%s/%s.cld", pt, dbname); |
|
622 |
+ snprintf(olddb, sizeof(olddb), "%s"PATHSEP"%s.cld", pt, dbname); |
|
623 | 623 |
free(pt); |
624 | 624 |
} |
625 | 625 |
|
... | ... |
@@ -910,9 +910,9 @@ static int unpack(const struct optstruct *opts) |
910 | 910 |
|
911 | 911 |
if(optget(opts, "unpack-current")->enabled) { |
912 | 912 |
dbdir = freshdbdir(); |
913 |
- snprintf(name, sizeof(name), "%s/%s.cvd", dbdir, optget(opts, "unpack-current")->strarg); |
|
913 |
+ snprintf(name, sizeof(name), "%s"PATHSEP"%s.cvd", dbdir, optget(opts, "unpack-current")->strarg); |
|
914 | 914 |
if(access(name, R_OK)) { |
915 |
- snprintf(name, sizeof(name), "%s/%s.cld", dbdir, optget(opts, "unpack-current")->strarg); |
|
915 |
+ snprintf(name, sizeof(name), "%s"PATHSEP"%s.cld", dbdir, optget(opts, "unpack-current")->strarg); |
|
916 | 916 |
if(access(name, R_OK)) { |
917 | 917 |
mprintf("!unpack: Couldn't find %s CLD/CVD database\n", optget(opts, "unpack-current")->strarg); |
918 | 918 |
free(dbdir); |
... | ... |
@@ -1013,7 +1013,7 @@ static int listdir(const char *dirname) |
1013 | 1013 |
closedir(dd); |
1014 | 1014 |
return -1; |
1015 | 1015 |
} |
1016 |
- sprintf(dbfile, "%s/%s", dirname, dent->d_name); |
|
1016 |
+ sprintf(dbfile, "%s"PATHSEP"%s", dirname, dent->d_name); |
|
1017 | 1017 |
|
1018 | 1018 |
if(listdb(dbfile) == -1) { |
1019 | 1019 |
mprintf("!listdb: Error listing database %s\n", dbfile); |
... | ... |
@@ -1466,8 +1466,8 @@ static int dircopy(const char *src, const char *dest) |
1466 | 1466 |
if(!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, "..")) |
1467 | 1467 |
continue; |
1468 | 1468 |
|
1469 |
- snprintf(spath, sizeof(spath), "%s/%s", src, dent->d_name); |
|
1470 |
- snprintf(dpath, sizeof(dpath), "%s/%s", dest, dent->d_name); |
|
1469 |
+ snprintf(spath, sizeof(spath), "%s"PATHSEP"%s", src, dent->d_name); |
|
1470 |
+ snprintf(dpath, sizeof(dpath), "%s"PATHSEP"%s", dest, dent->d_name); |
|
1471 | 1471 |
|
1472 | 1472 |
if(filecopy(spath, dpath) == -1) { |
1473 | 1473 |
/* mprintf("!dircopy: Can't copy %s to %s\n", spath, dpath); */ |
... | ... |
@@ -1612,7 +1612,7 @@ static int diffdirs(const char *old, const char *new, const char *patch) |
1612 | 1612 |
if(!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, "..")) |
1613 | 1613 |
continue; |
1614 | 1614 |
|
1615 |
- snprintf(path, sizeof(path), "%s/%s", old, dent->d_name); |
|
1615 |
+ snprintf(path, sizeof(path), "%s"PATHSEP"%s", old, dent->d_name); |
|
1616 | 1616 |
if(compare(path, dent->d_name, diff) == -1) { |
1617 | 1617 |
if(chdir(cwd) == -1) |
1618 | 1618 |
mprintf("^diffdirs: Can't chdir to %s\n", cwd); |
... | ... |
@@ -1638,7 +1638,7 @@ static int diffdirs(const char *old, const char *new, const char *patch) |
1638 | 1638 |
if(!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, "..")) |
1639 | 1639 |
continue; |
1640 | 1640 |
|
1641 |
- snprintf(path, sizeof(path), "%s/%s", new, dent->d_name); |
|
1641 |
+ snprintf(path, sizeof(path), "%s"PATHSEP"%s", new, dent->d_name); |
|
1642 | 1642 |
if(access(path, R_OK)) |
1643 | 1643 |
fprintf(diff, "UNLINK %s\n", dent->d_name); |
1644 | 1644 |
} |
... | ... |
@@ -974,7 +974,7 @@ static int sigtool_scandir (const char *dirname, int hex_output) |
974 | 974 |
if (strcmp (dent->d_name, ".") && strcmp (dent->d_name, "..")) { |
975 | 975 |
/* build the full name */ |
976 | 976 |
fname = (char *) cli_calloc (strlen (dirname) + strlen (dent->d_name) + 2, sizeof (char)); |
977 |
- sprintf (fname, "%s/%s", dirname, dent->d_name); |
|
977 |
+ sprintf (fname, "%s"PATHSEP"%s", dirname, dent->d_name); |
|
978 | 978 |
|
979 | 979 |
/* stat the file */ |
980 | 980 |
if (lstat (fname, &statbuf) != -1) { |
... | ... |
@@ -1047,7 +1047,7 @@ int sigtool_vba_scandir (const char *dirname, int hex_output, struct uniq *U) |
1047 | 1047 |
|
1048 | 1048 |
for(i = 0; i < vba_project->count; i++) { |
1049 | 1049 |
for(j = 0; j < vba_project->colls[i]; j++) { |
1050 |
- snprintf(vbaname, 1024, "%s/%s_%u", vba_project->dir, vba_project->name[i], j); |
|
1050 |
+ snprintf(vbaname, 1024, "%s"PATHSEP"%s_%u", vba_project->dir, vba_project->name[i], j); |
|
1051 | 1051 |
vbaname[sizeof(vbaname)-1] = '\0'; |
1052 | 1052 |
fd = open(vbaname, O_RDONLY|O_BINARY); |
1053 | 1053 |
if(fd == -1) continue; |
... | ... |
@@ -1073,7 +1073,7 @@ int sigtool_vba_scandir (const char *dirname, int hex_output, struct uniq *U) |
1073 | 1073 |
|
1074 | 1074 |
if((hashcnt = uniq_get(U, "powerpoint document", 19, &hash))) { |
1075 | 1075 |
while(hashcnt--) { |
1076 |
- snprintf(vbaname, 1024, "%s/%s_%u", dirname, hash, hashcnt); |
|
1076 |
+ snprintf(vbaname, 1024, "%s"PATHSEP"%s_%u", dirname, hash, hashcnt); |
|
1077 | 1077 |
vbaname[sizeof(vbaname)-1] = '\0'; |
1078 | 1078 |
fd = open(vbaname, O_RDONLY|O_BINARY); |
1079 | 1079 |
if (fd == -1) continue; |
... | ... |
@@ -1089,7 +1089,7 @@ int sigtool_vba_scandir (const char *dirname, int hex_output, struct uniq *U) |
1089 | 1089 |
|
1090 | 1090 |
if ((hashcnt = uniq_get(U, "worddocument", 12, &hash))) { |
1091 | 1091 |
while(hashcnt--) { |
1092 |
- snprintf(vbaname, sizeof(vbaname), "%s/%s_%u", dirname, hash, hashcnt); |
|
1092 |
+ snprintf(vbaname, sizeof(vbaname), "%s"PATHSEP"%s_%u", dirname, hash, hashcnt); |
|
1093 | 1093 |
vbaname[sizeof(vbaname)-1] = '\0'; |
1094 | 1094 |
fd = open(vbaname, O_RDONLY|O_BINARY); |
1095 | 1095 |
if (fd == -1) continue; |
... | ... |
@@ -1127,7 +1127,7 @@ int sigtool_vba_scandir (const char *dirname, int hex_output, struct uniq *U) |
1127 | 1127 |
if (strcmp (dent->d_name, ".") && strcmp (dent->d_name, "..")) { |
1128 | 1128 |
/* build the full name */ |
1129 | 1129 |
fullname = calloc (strlen (dirname) + strlen (dent->d_name) + 2, sizeof (char)); |
1130 |
- sprintf (fullname, "%s/%s", dirname, dent->d_name); |
|
1130 |
+ sprintf (fullname, "%s"PATHSEP"%s", dirname, dent->d_name); |
|
1131 | 1131 |
|
1132 | 1132 |
/* stat the file */ |
1133 | 1133 |
if (lstat (fullname, &statbuf) != -1) { |