mirror of
https://github.com/php/php-src.git
synced 2025-01-19 10:13:38 +08:00
Fixed search on uninitialized data
This commit is contained in:
parent
5c631e8765
commit
67b77b06e5
@ -1427,7 +1427,9 @@ static inline char *phar_strnstr(const char *buf, int buf_len, const char *searc
|
||||
const char *c;
|
||||
int so_far = 0;
|
||||
|
||||
/* this assumes buf_len > search_len */
|
||||
if (buf_len < search_len) {
|
||||
return NULL;
|
||||
}
|
||||
c = buf - 1;
|
||||
do {
|
||||
if (!(c = memchr(c + 1, search[0], buf_len - search_len - so_far))) {
|
||||
@ -1579,7 +1581,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *a
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((pos = phar_strnstr(buffer, 1024 + sizeof(token), token, sizeof(token)-1)) != NULL) {
|
||||
if (got > 0 && (pos = phar_strnstr(buffer, got + sizeof(token), token, sizeof(token)-1)) != NULL) {
|
||||
halt_offset += (pos - buffer); /* no -tokenlen+tokenlen here */
|
||||
return phar_parse_pharfile(fp, fname, fname_len, alias, alias_len, halt_offset, pphar, compression, error TSRMLS_CC);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user