Skip to content

Commit f45925f

Browse files
committed
Fix GH-16409: Segfault in exif_thumbnail when not dealing with a real file
1 parent 1d0fbdf commit f45925f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

ext/exif/exif.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4419,7 +4419,7 @@ static bool exif_read_from_impl(image_info_type *ImageInfo, php_stream *stream,
44194419
ImageInfo->FileName = NULL;
44204420

44214421
if (php_stream_is(ImageInfo->infile, PHP_STREAM_IS_STDIO)) {
4422-
if (VCWD_STAT(stream->orig_path, &st) >= 0) {
4422+
if (stream->orig_path && VCWD_STAT(stream->orig_path, &st) >= 0) {
44234423
zend_string *base;
44244424
if ((st.st_mode & S_IFMT) != S_IFREG) {
44254425
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Not a file");

ext/exif/tests/gh16409.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
GH-16409 (Segfault in exif_thumbnail when not dealing with a real file)
3+
--EXTENSIONS--
4+
exif
5+
--SKIPIF--
6+
<?php
7+
if (PHP_OS_FAMILY === "Windows") die("skip *nix only");
8+
?>
9+
--FILE--
10+
<?php
11+
$stream = popen('echo 1', 'r');
12+
var_dump(exif_thumbnail($stream, $pipes, $stream, $pipes));
13+
?>
14+
--EXPECTF--
15+
Warning: exif_thumbnail(): File too small (0) in %s on line %d
16+
bool(false)
17+
%A

0 commit comments

Comments
 (0)