Skip to content

Commit

Permalink
fix unchecked emalloc
Browse files Browse the repository at this point in the history
(cherry picked from commit 158d8a6)
  • Loading branch information
smalyshev authored and johannes committed May 30, 2012
1 parent a331f43 commit fa05f03
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ext/phar/tar.c
Expand Up @@ -38,7 +38,7 @@ static php_uint32 phar_tar_number(char *buf, int len) /* {{{ */
/* }}} */ /* }}} */


/* adapted from format_octal() in libarchive /* adapted from format_octal() in libarchive
* *
* Copyright (c) 2003-2009 Tim Kientzle * Copyright (c) 2003-2009 Tim Kientzle
* All rights reserved. * All rights reserved.
* *
Expand Down Expand Up @@ -161,7 +161,7 @@ static int phar_tar_process_metadata(phar_entry_info *entry, php_stream *fp TSRM
size_t save = php_stream_tell(fp), read; size_t save = php_stream_tell(fp), read;
phar_entry_info *mentry; phar_entry_info *mentry;


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


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


read = php_stream_read(fp, buf, sizeof(buf)); read = php_stream_read(fp, buf, sizeof(buf));

if (read != sizeof(buf)) { if (read != sizeof(buf)) {
efree(entry.filename); efree(entry.filename);
if (error) { if (error) {
Expand Down

0 comments on commit fa05f03

Please sign in to comment.