mirror of
https://github.com/Cisco-Talos/clamav.git
synced 2025-10-19 18:33:16 +00:00
Change permission for new tmp files from RWX to RW
This commit is contained in:
parent
52098c5f57
commit
c110392780
8 changed files with 27 additions and 27 deletions
|
@ -836,7 +836,7 @@ static int ea05(cli_ctx *ctx, const uint8_t *base, char *tmpd)
|
||||||
|
|
||||||
snprintf(tempfile, 1023, "%s" PATHSEP "autoit.%.3u", tmpd, files);
|
snprintf(tempfile, 1023, "%s" PATHSEP "autoit.%.3u", tmpd, files);
|
||||||
tempfile[1023] = '\0';
|
tempfile[1023] = '\0';
|
||||||
if ((i = open(tempfile, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU)) < 0) {
|
if ((i = open(tempfile, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR)) < 0) {
|
||||||
cli_dbgmsg("autoit: Can't create file %s\n", tempfile);
|
cli_dbgmsg("autoit: Can't create file %s\n", tempfile);
|
||||||
free(UNP.outputbuf);
|
free(UNP.outputbuf);
|
||||||
return CL_ECREAT;
|
return CL_ECREAT;
|
||||||
|
@ -1445,7 +1445,7 @@ static int ea06(cli_ctx *ctx, const uint8_t *base, char *tmpd)
|
||||||
|
|
||||||
snprintf(tempfile, 1023, "%s" PATHSEP "autoit.%.3u", tmpd, files);
|
snprintf(tempfile, 1023, "%s" PATHSEP "autoit.%.3u", tmpd, files);
|
||||||
tempfile[1023] = '\0';
|
tempfile[1023] = '\0';
|
||||||
if ((i = open(tempfile, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU)) < 0) {
|
if ((i = open(tempfile, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR)) < 0) {
|
||||||
cli_dbgmsg("autoit: Can't create file %s\n", tempfile);
|
cli_dbgmsg("autoit: Can't create file %s\n", tempfile);
|
||||||
free(buf);
|
free(buf);
|
||||||
return CL_ECREAT;
|
return CL_ECREAT;
|
||||||
|
|
|
@ -1115,7 +1115,7 @@ static int dmg_extract_xml(cli_ctx *ctx, char *dir, struct dmg_koly_block *hdr)
|
||||||
cli_dbgmsg("cli_scandmg: Extracting XML as %s\n", xmlfile);
|
cli_dbgmsg("cli_scandmg: Extracting XML as %s\n", xmlfile);
|
||||||
|
|
||||||
/* Write out TOC XML */
|
/* Write out TOC XML */
|
||||||
if ((ofd = open(xmlfile, O_CREAT | O_RDWR | O_EXCL | O_TRUNC | O_BINARY, S_IRWXU)) < 0) {
|
if ((ofd = open(xmlfile, O_CREAT | O_RDWR | O_EXCL | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR)) < 0) {
|
||||||
char err[128];
|
char err[128];
|
||||||
cli_errmsg("cli_scandmg: Can't create temporary file %s: %s\n",
|
cli_errmsg("cli_scandmg: Can't create temporary file %s: %s\n",
|
||||||
xmlfile, cli_strerror(errno, err, sizeof(err)));
|
xmlfile, cli_strerror(errno, err, sizeof(err)));
|
||||||
|
|
|
@ -3583,7 +3583,7 @@ rfc1341(mbox_ctx *mctx, message *m)
|
||||||
|
|
||||||
snprintf(pdir, sizeof(pdir) - 1, "%s" PATHSEP "clamav-partial", tmpdir);
|
snprintf(pdir, sizeof(pdir) - 1, "%s" PATHSEP "clamav-partial", tmpdir);
|
||||||
|
|
||||||
if ((mkdir(pdir, S_IRWXU) < 0) && (errno != EEXIST)) {
|
if ((mkdir(pdir, S_IRUSR | S_IWUSR) < 0) && (errno != EEXIST)) {
|
||||||
cli_errmsg("Can't create the directory '%s'\n", pdir);
|
cli_errmsg("Can't create the directory '%s'\n", pdir);
|
||||||
free(id);
|
free(id);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -4528,7 +4528,7 @@ do_multipart(message *mainMessage, message **messages, int i, mbox_status *rc, m
|
||||||
dtype = json_object_get_string(entry);
|
dtype = json_object_get_string(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cli_jsonint(thisobj, "ContainedObjectsIndex", (uint32_t)arrlen);
|
cli_jsonint(thisobj, "ContainedObjectsIndex", (int32_t)arrlen);
|
||||||
cli_jsonstr(thisobj, "ClamAVFileType", dtype ? dtype : "UNKNOWN");
|
cli_jsonstr(thisobj, "ClamAVFileType", dtype ? dtype : "UNKNOWN");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -833,7 +833,7 @@ handler_writefile(ole2_header_t *hdr, property_t *prop, const char *dir, cli_ctx
|
||||||
if (name)
|
if (name)
|
||||||
free(name);
|
free(name);
|
||||||
|
|
||||||
ofd = open(newname, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU);
|
ofd = open(newname, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR);
|
||||||
if (ofd < 0) {
|
if (ofd < 0) {
|
||||||
cli_errmsg("OLE2 [handler_writefile]: failed to create file: %s\n", newname);
|
cli_errmsg("OLE2 [handler_writefile]: failed to create file: %s\n", newname);
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
|
@ -1462,7 +1462,7 @@ handler_otf(ole2_header_t *hdr, property_t *prop, const char *dir, cli_ctx *ctx)
|
||||||
if (!(tempfile = cli_gentemp(ctx ? ctx->sub_tmpdir : NULL)))
|
if (!(tempfile = cli_gentemp(ctx ? ctx->sub_tmpdir : NULL)))
|
||||||
return CL_EMEM;
|
return CL_EMEM;
|
||||||
|
|
||||||
if ((ofd = open(tempfile, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU)) < 0) {
|
if ((ofd = open(tempfile, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR)) < 0) {
|
||||||
cli_dbgmsg("OLE2: Can't create file %s\n", tempfile);
|
cli_dbgmsg("OLE2: Can't create file %s\n", tempfile);
|
||||||
free(tempfile);
|
free(tempfile);
|
||||||
return CL_ECREAT;
|
return CL_ECREAT;
|
||||||
|
|
|
@ -434,7 +434,7 @@ int cli_filecopy(const char *src, const char *dest)
|
||||||
if ((s = open(src, O_RDONLY | O_BINARY)) == -1)
|
if ((s = open(src, O_RDONLY | O_BINARY)) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if ((d = open(dest, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, S_IRWXU)) == -1) {
|
if ((d = open(dest, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR)) == -1) {
|
||||||
close(s);
|
close(s);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1051,7 +1051,7 @@ cl_error_t cli_newfilepathfd(const char *dir, char *fname, char **name, int *fd)
|
||||||
if (!*name)
|
if (!*name)
|
||||||
return CL_EMEM;
|
return CL_EMEM;
|
||||||
|
|
||||||
*fd = open(*name, O_RDWR | O_CREAT | O_TRUNC | O_BINARY | O_EXCL, S_IRWXU);
|
*fd = open(*name, O_RDWR | O_CREAT | O_TRUNC | O_BINARY | O_EXCL, S_IRUSR | S_IWUSR);
|
||||||
/*
|
/*
|
||||||
* EEXIST is almost impossible to occur, so we just treat it as other
|
* EEXIST is almost impossible to occur, so we just treat it as other
|
||||||
* errors
|
* errors
|
||||||
|
@ -1111,7 +1111,7 @@ cl_error_t cli_gentempfd_with_prefix(const char *dir, char *prefix, char **name,
|
||||||
if (!*name)
|
if (!*name)
|
||||||
return CL_EMEM;
|
return CL_EMEM;
|
||||||
|
|
||||||
*fd = open(*name, O_RDWR | O_CREAT | O_TRUNC | O_BINARY | O_EXCL, S_IRWXU);
|
*fd = open(*name, O_RDWR | O_CREAT | O_TRUNC | O_BINARY | O_EXCL, S_IRUSR | S_IWUSR);
|
||||||
/*
|
/*
|
||||||
* EEXIST is almost impossible to occur, so we just treat it as other
|
* EEXIST is almost impossible to occur, so we just treat it as other
|
||||||
* errors
|
* errors
|
||||||
|
@ -1123,7 +1123,7 @@ cl_error_t cli_gentempfd_with_prefix(const char *dir, char *prefix, char **name,
|
||||||
*name = cli_gentemp(dir);
|
*name = cli_gentemp(dir);
|
||||||
if (!*name)
|
if (!*name)
|
||||||
return CL_EMEM;
|
return CL_EMEM;
|
||||||
*fd = open(*name, O_RDWR | O_CREAT | O_TRUNC | O_BINARY | O_EXCL, S_IRWXU);
|
*fd = open(*name, O_RDWR | O_CREAT | O_TRUNC | O_BINARY | O_EXCL, S_IRUSR | S_IWUSR);
|
||||||
if (*fd == -1) {
|
if (*fd == -1) {
|
||||||
cli_errmsg("cli_gentempfd_with_prefix: Can't create temporary file %s: %s\n", *name, strerror(errno));
|
cli_errmsg("cli_gentempfd_with_prefix: Can't create temporary file %s: %s\n", *name, strerror(errno));
|
||||||
free(*name);
|
free(*name);
|
||||||
|
|
|
@ -125,18 +125,18 @@
|
||||||
return CL_CLEAN; \
|
return CL_CLEAN; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CLI_UNPTEMP(NAME, FREEME) \
|
#define CLI_UNPTEMP(NAME, FREEME) \
|
||||||
if (!(tempfile = cli_gentemp(ctx->sub_tmpdir))) { \
|
if (!(tempfile = cli_gentemp(ctx->sub_tmpdir))) { \
|
||||||
cli_exe_info_destroy(peinfo); \
|
cli_exe_info_destroy(peinfo); \
|
||||||
cli_multifree FREEME; \
|
cli_multifree FREEME; \
|
||||||
return CL_EMEM; \
|
return CL_EMEM; \
|
||||||
} \
|
} \
|
||||||
if ((ndesc = open(tempfile, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU)) < 0) { \
|
if ((ndesc = open(tempfile, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR)) < 0) { \
|
||||||
cli_dbgmsg(NAME ": Can't create file %s\n", tempfile); \
|
cli_dbgmsg(NAME ": Can't create file %s\n", tempfile); \
|
||||||
free(tempfile); \
|
free(tempfile); \
|
||||||
cli_exe_info_destroy(peinfo); \
|
cli_exe_info_destroy(peinfo); \
|
||||||
cli_multifree FREEME; \
|
cli_multifree FREEME; \
|
||||||
return CL_ECREAT; \
|
return CL_ECREAT; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CLI_TMPUNLK() \
|
#define CLI_TMPUNLK() \
|
||||||
|
|
|
@ -2251,7 +2251,7 @@ static cl_error_t cli_scanhtml_utf16(cli_ctx *ctx)
|
||||||
if (!(tempname = cli_gentemp_with_prefix(ctx->sub_tmpdir, "html-utf16-tmp")))
|
if (!(tempname = cli_gentemp_with_prefix(ctx->sub_tmpdir, "html-utf16-tmp")))
|
||||||
return CL_EMEM;
|
return CL_EMEM;
|
||||||
|
|
||||||
if ((fd = open(tempname, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU)) < 0) {
|
if ((fd = open(tempname, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR)) < 0) {
|
||||||
cli_errmsg("cli_scanhtml_utf16: Can't create file %s\n", tempname);
|
cli_errmsg("cli_scanhtml_utf16: Can't create file %s\n", tempname);
|
||||||
free(tempname);
|
free(tempname);
|
||||||
return CL_EOPEN;
|
return CL_EOPEN;
|
||||||
|
@ -2463,7 +2463,7 @@ static cl_error_t cli_scancryptff(cli_ctx *ctx)
|
||||||
return CL_EMEM;
|
return CL_EMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ndesc = open(tempfile, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU)) < 0) {
|
if ((ndesc = open(tempfile, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR)) < 0) {
|
||||||
cli_errmsg("CryptFF: Can't create file %s\n", tempfile);
|
cli_errmsg("CryptFF: Can't create file %s\n", tempfile);
|
||||||
free(dest);
|
free(dest);
|
||||||
free(tempfile);
|
free(tempfile);
|
||||||
|
@ -2722,7 +2722,7 @@ static cl_error_t cli_scanembpe(cli_ctx *ctx, off_t offset)
|
||||||
if (!tmpname)
|
if (!tmpname)
|
||||||
return CL_EMEM;
|
return CL_EMEM;
|
||||||
|
|
||||||
if ((fd = open(tmpname, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU)) < 0) {
|
if ((fd = open(tmpname, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR)) < 0) {
|
||||||
cli_errmsg("cli_scanembpe: Can't create file %s\n", tmpname);
|
cli_errmsg("cli_scanembpe: Can't create file %s\n", tmpname);
|
||||||
free(tmpname);
|
free(tmpname);
|
||||||
return CL_ECREAT;
|
return CL_ECREAT;
|
||||||
|
|
|
@ -458,7 +458,7 @@ static int utf16decode(const struct optstruct *opts)
|
||||||
}
|
}
|
||||||
sprintf(newname, "%s.ascii", fname);
|
sprintf(newname, "%s.ascii", fname);
|
||||||
|
|
||||||
if ((fd2 = open(newname, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU)) < 0) {
|
if ((fd2 = open(newname, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) < 0) {
|
||||||
mprintf("!utf16decode: Can't create file %s\n", newname);
|
mprintf("!utf16decode: Can't create file %s\n", newname);
|
||||||
free(newname);
|
free(newname);
|
||||||
close(fd1);
|
close(fd1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue