Skip to content

Commit 523bf03

Browse files
committed
fix unchecked emalloc
1 parent 9b33585 commit 523bf03

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/phar/tar.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static php_uint32 phar_tar_number(char *buf, int len) /* {{{ */
3838
/* }}} */
3939

4040
/* adapted from format_octal() in libarchive
41-
*
41+
*
4242
* Copyright (c) 2003-2009 Tim Kientzle
4343
* All rights reserved.
4444
*
@@ -161,7 +161,7 @@ static int phar_tar_process_metadata(phar_entry_info *entry, php_stream *fp TSRM
161161
size_t save = php_stream_tell(fp), read;
162162
phar_entry_info *mentry;
163163

164-
metadata = (char *) emalloc(entry->uncompressed_filesize + 1);
164+
metadata = (char *) safe_emalloc(1, entry->uncompressed_filesize, 1);
165165

166166
read = php_stream_read(fp, metadata, entry->uncompressed_filesize);
167167
if (read != entry->uncompressed_filesize) {
@@ -377,7 +377,7 @@ int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias,
377377
}
378378

379379
read = php_stream_read(fp, buf, sizeof(buf));
380-
380+
381381
if (read != sizeof(buf)) {
382382
efree(entry.filename);
383383
if (error) {

0 commit comments

Comments
 (0)