EVLOG will cause a program to crash if the file that is
identified as the log file is opened with posix_log_open().
The fix is to check if the file is explicitly empty
before allowing an mmap to be established for the header.
diff -Naur evlog-1.6.1-orig/user/lib/posix2.c
evlog-1.6.1/user/lib/posix2.c
--- evlog-1.6.1-orig/user/lib/posix2.c 2006-07-27
09:27:45.000000000 -0700
+++ evlog-1.6.1/user/lib/posix2.c 2006-07-27
09:21:07.000000000 -0700
@@ -214,8 +214,9 @@
log_desc_t *logd;
log_header_t *logHdr;
void *mappedLog;
+ struct stat64 st;
- if (path == 0) {
+ if (path == (char *) NULL) {
path = LOG_CURLOG_PATH;
}
@@ -224,6 +225,14 @@
return errno;
}
+ if (fstat64(fd, &st) == -1) {
+ return errno;
+ }
+
+ if (st.st_size == 0) {
+ return EINVAL;
+ }
+
logd = makeLogDescription();
logd->ld_fd = fd;