Skip to content

Commit bc49200

Browse files
committed
Fixed Bug #63581 Possible buffer overflow
In fpm-log, possible buffer overflow. Check for length is done at the beginning of the loop, so is not done when overflow occurs on the last loop (len = 1024 or 1025). (ack from fat). This issue where found from by static code analysis tool and, so, I can't provide any reproducer.
1 parent f08060a commit bc49200

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ PHP NEWS
2121
. Fixed bug #63590 (Different results in TS and NTS under Windows).
2222
(Anatoliy)
2323

24+
- FPM:
25+
. Fixed bug #63581 Possible null dereference and buffer overflow (Remi)
26+
2427
- Imap:
2528
. Fixed Bug #63126 DISABLE_AUTHENTICATOR ignores array (Remi)
2629

sapi/fpm/fpm/fpm_log.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ int fpm_log_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
9696
int fpm_log_write(char *log_format TSRMLS_DC) /* {{{ */
9797
{
9898
char *s, *b;
99-
char buffer[FPM_LOG_BUFFER];
99+
char buffer[FPM_LOG_BUFFER+1];
100100
int token, test;
101101
size_t len, len2;
102102
struct fpm_scoreboard_proc_s proc, *proc_p;
@@ -146,9 +146,10 @@ int fpm_log_write(char *log_format TSRMLS_DC) /* {{{ */
146146
s = log_format;
147147

148148
while (*s != '\0') {
149-
if (len > FPM_LOG_BUFFER) {
149+
/* Test is we have place for 1 more char. */
150+
if (len >= FPM_LOG_BUFFER) {
150151
zlog(ZLOG_NOTICE, "the log buffer is full (%d). The access log request has been truncated.", FPM_LOG_BUFFER);
151-
len = FPM_LOG_BUFFER - 1;
152+
len = FPM_LOG_BUFFER;
152153
break;
153154
}
154155

0 commit comments

Comments
 (0)