Skip to content

Commit

Permalink
Merge branch 'PHP-8.4'
Browse files Browse the repository at this point in the history
* PHP-8.4:
  Fix phpGH-16409: Segfault in exif_thumbnail when not dealing with a real file
  • Loading branch information
nielsdos committed Oct 13, 2024
2 parents 810a121 + 63c9d12 commit 41c55d1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ext/exif/exif.c
Original file line number Diff line number Diff line change
Expand Up @@ -4395,7 +4395,7 @@ static bool exif_read_from_impl(image_info_type *ImageInfo, php_stream *stream,
ImageInfo->FileName = NULL;

if (php_stream_is(ImageInfo->infile, PHP_STREAM_IS_STDIO)) {
if (VCWD_STAT(stream->orig_path, &st) >= 0) {
if (stream->orig_path && VCWD_STAT(stream->orig_path, &st) >= 0) {
zend_string *base;
if ((st.st_mode & S_IFMT) != S_IFREG) {
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Not a file");
Expand Down
12 changes: 12 additions & 0 deletions ext/exif/tests/gh16409.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
GH-16409 (Segfault in exif_thumbnail when not dealing with a real file)
--EXTENSIONS--
exif
--FILE--
<?php
$stream = popen('echo 1', 'r');
var_dump(exif_thumbnail($stream, $pipes, $stream, $pipes));
?>
--EXPECTF--
Warning: exif_thumbnail(): File too small (0) in %s on line %d
bool(false)%A

0 comments on commit 41c55d1

Please sign in to comment.