mirror of
https://github.com/Cisco-Talos/clamav.git
synced 2025-10-19 10:23:17 +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);
|
||||
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);
|
||||
free(UNP.outputbuf);
|
||||
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);
|
||||
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);
|
||||
free(buf);
|
||||
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);
|
||||
|
||||
/* 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];
|
||||
cli_errmsg("cli_scandmg: Can't create temporary file %s: %s\n",
|
||||
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);
|
||||
|
||||
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);
|
||||
free(id);
|
||||
return -1;
|
||||
|
@ -4528,7 +4528,7 @@ do_multipart(message *mainMessage, message **messages, int i, mbox_status *rc, m
|
|||
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");
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -833,7 +833,7 @@ handler_writefile(ole2_header_t *hdr, property_t *prop, const char *dir, cli_ctx
|
|||
if (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) {
|
||||
cli_errmsg("OLE2 [handler_writefile]: failed to create file: %s\n", newname);
|
||||
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)))
|
||||
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);
|
||||
free(tempfile);
|
||||
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)
|
||||
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);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1051,7 +1051,7 @@ cl_error_t cli_newfilepathfd(const char *dir, char *fname, char **name, int *fd)
|
|||
if (!*name)
|
||||
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
|
||||
* errors
|
||||
|
@ -1111,7 +1111,7 @@ cl_error_t cli_gentempfd_with_prefix(const char *dir, char *prefix, char **name,
|
|||
if (!*name)
|
||||
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
|
||||
* errors
|
||||
|
@ -1123,7 +1123,7 @@ cl_error_t cli_gentempfd_with_prefix(const char *dir, char *prefix, char **name,
|
|||
*name = cli_gentemp(dir);
|
||||
if (!*name)
|
||||
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) {
|
||||
cli_errmsg("cli_gentempfd_with_prefix: Can't create temporary file %s: %s\n", *name, strerror(errno));
|
||||
free(*name);
|
||||
|
|
|
@ -125,18 +125,18 @@
|
|||
return CL_CLEAN; \
|
||||
}
|
||||
|
||||
#define CLI_UNPTEMP(NAME, FREEME) \
|
||||
if (!(tempfile = cli_gentemp(ctx->sub_tmpdir))) { \
|
||||
cli_exe_info_destroy(peinfo); \
|
||||
cli_multifree FREEME; \
|
||||
return CL_EMEM; \
|
||||
} \
|
||||
if ((ndesc = open(tempfile, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU)) < 0) { \
|
||||
cli_dbgmsg(NAME ": Can't create file %s\n", tempfile); \
|
||||
free(tempfile); \
|
||||
cli_exe_info_destroy(peinfo); \
|
||||
cli_multifree FREEME; \
|
||||
return CL_ECREAT; \
|
||||
#define CLI_UNPTEMP(NAME, FREEME) \
|
||||
if (!(tempfile = cli_gentemp(ctx->sub_tmpdir))) { \
|
||||
cli_exe_info_destroy(peinfo); \
|
||||
cli_multifree FREEME; \
|
||||
return CL_EMEM; \
|
||||
} \
|
||||
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); \
|
||||
free(tempfile); \
|
||||
cli_exe_info_destroy(peinfo); \
|
||||
cli_multifree FREEME; \
|
||||
return CL_ECREAT; \
|
||||
}
|
||||
|
||||
#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")))
|
||||
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);
|
||||
free(tempname);
|
||||
return CL_EOPEN;
|
||||
|
@ -2463,7 +2463,7 @@ static cl_error_t cli_scancryptff(cli_ctx *ctx)
|
|||
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);
|
||||
free(dest);
|
||||
free(tempfile);
|
||||
|
@ -2722,7 +2722,7 @@ static cl_error_t cli_scanembpe(cli_ctx *ctx, off_t offset)
|
|||
if (!tmpname)
|
||||
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);
|
||||
free(tmpname);
|
||||
return CL_ECREAT;
|
||||
|
|
|
@ -458,7 +458,7 @@ static int utf16decode(const struct optstruct *opts)
|
|||
}
|
||||
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);
|
||||
free(newname);
|
||||
close(fd1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue