com php-src: Fix event log handling in startup phase: win32/wsyslog.c
| From: | Anatol Belski | Date: | Fri, 06 Jul 2018 14:07:28 +0000 |
| Subject: | com php-src: Fix event log handling in startup phase: win32/wsyslog.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-102449@lists.php.net to get a copy of this message | ||
Commit: 246cb03e261a8fb499a1cdb70d609a19c26a6574
Author: Anatol Belski <ab@php.net> Fri, 6 Jul 2018 13:59:14 +0200
Parents: 3847a6fcb63c362548e9434b195232f2dcf7a6c7
Branches: PHP-7.1 PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=246cb03e261a8fb499a1cdb70d609a19c26a6574
Log:
Fix event log handling in startup phase
The log header can be saved in the globals on startup. At the same
time, the log header can be changed per request. In case that
happened, wrong pointer will be free'd on shutdown. It can happen at
any point when zend_error() or similar is called at startup, like for
example in the case of the ini deprecation warnings. Thus, ZMM cannot
be used here.
Changed paths:
M win32/wsyslog.c
Diff:
diff --git a/win32/wsyslog.c b/win32/wsyslog.c
index 6b0f03e..73f9969 100644
--- a/win32/wsyslog.c
+++ b/win32/wsyslog.c
@@ -66,7 +66,7 @@ void closelog(void)
PW32G(log_source) = INVALID_HANDLE_VALUE;
}
if (PW32G(log_header)) {
- efree(PW32G(log_header));
+ free(PW32G(log_header));
PW32G(log_header) = NULL;
}
}
@@ -112,7 +112,6 @@ void syslog(int priority, const char *message, ...)
efree(tmp);
}
-
/* Emulator for BSD openlog() routine
* Accepts: identity
* options
@@ -121,11 +120,14 @@ void syslog(int priority, const char *message, ...)
void openlog(const char *ident, int logopt, int facility)
{
+ size_t header_len;
closelog();
PW32G(log_source) = RegisterEventSource(NULL, "PHP-" PHP_VERSION);
- spprintf(&PW32G(log_header), 0, (logopt & LOG_PID) ? "%s[%d]" : "%s",
ident, getpid());
+ header_len = strlen(ident) + 2 + 11;
+ PW32G(log_header) = malloc(header_len*sizeof(char));
+ sprintf_s(PW32G(log_header), header_len, (logopt & LOG_PID) ? "%s[%d]" :
"%s", ident, getpid());
}
/*