diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2011-04-05 13:59:51 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2011-04-05 13:59:51 +0000 |
commit | 8595545317cb1c30a0a59dbd8fc3426b1cab6282 (patch) | |
tree | cb226e7cc63e6bd05be49fa4ee46d0cf3026e484 /main/logrotate/logrotate-3.7.9-atomic-create.patch | |
parent | 2b513dbb1c52763aa686ec32a54697f26bce12a7 (diff) | |
download | aports-1.10-stable.tar.bz2 aports-1.10-stable.tar.xz |
main/logrotate: security fixes1.10-stable
fixes #568
fix CVE-2011-1154, CVE-2011-1155 and CVE-2011-1098
(cherry picked from commit e30653b7a5011b09138e547bd80561ccba16f0c4)
Conflicts:
main/logrotate/APKBUILD
Diffstat (limited to 'main/logrotate/logrotate-3.7.9-atomic-create.patch')
-rw-r--r-- | main/logrotate/logrotate-3.7.9-atomic-create.patch | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/main/logrotate/logrotate-3.7.9-atomic-create.patch b/main/logrotate/logrotate-3.7.9-atomic-create.patch new file mode 100644 index 00000000..b888dc02 --- /dev/null +++ b/main/logrotate/logrotate-3.7.9-atomic-create.patch @@ -0,0 +1,70 @@ +diff --git a/logrotate.c b/logrotate.c +index 3748918..fbe232a 100644 +--- a/logrotate.c ++++ b/logrotate.c +@@ -194,31 +194,41 @@ static int runScript(char *logfn, char *script) + int createOutputFile(char *fileName, int flags, struct stat *sb) + { + int fd; ++ char template[PATH_MAX + 1]; ++ mode_t umask_value; ++ snprintf(template, PATH_MAX, "%s/logrotate_temp.XXXXXX", ourDirName(fileName)); ++ ++ umask_value = umask(0000); ++ fd = mkstemp(template); ++ umask(umask_value); ++ ++ if (fd < 0) { ++ message(MESS_ERROR, "error creating unique temp file: %s\n", ++ strerror(errno)); ++ return -1; ++ } ++ ++ if (fchown(fd, sb->st_uid, sb->st_gid)) { ++ message(MESS_ERROR, "error setting owner of %s: %s\n", ++ fileName, strerror(errno)); ++ close(fd); ++ return -1; ++ } ++ ++ if (fchmod(fd, sb->st_mode)) { ++ message(MESS_ERROR, "error setting mode of %s: %s\n", ++ fileName, strerror(errno)); ++ close(fd); ++ return -1; ++ } ++ ++ if (rename(template, fileName)) { ++ message(MESS_ERROR, "error renaming temp file to %s: %s\n", ++ fileName, strerror(errno)); ++ close(fd); ++ return -1; ++ } + +- fd = open(fileName, flags, sb->st_mode); +- if (fd < 0) { +- message(MESS_ERROR, "error creating output file %s: %s\n", +- fileName, strerror(errno)); +- return -1; +- } +- if (fchmod(fd, (S_IRUSR | S_IWUSR) & sb->st_mode)) { +- message(MESS_ERROR, "error setting mode of %s: %s\n", +- fileName, strerror(errno)); +- close(fd); +- return -1; +- } +- if (fchown(fd, sb->st_uid, sb->st_gid)) { +- message(MESS_ERROR, "error setting owner of %s: %s\n", +- fileName, strerror(errno)); +- close(fd); +- return -1; +- } +- if (fchmod(fd, sb->st_mode)) { +- message(MESS_ERROR, "error setting mode of %s: %s\n", +- fileName, strerror(errno)); +- close(fd); +- return -1; +- } + return fd; + } + |