Skip to content

Commit 3843f0e

Browse files
committed
Fix GH-16409: Segfault in exif_thumbnail when not dealing with a real file
Closes GH-16416.
1 parent d70b781 commit 3843f0e

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ PHP NEWS
1717
. Fixed bug GH-16316 (DOMXPath breaks when not initialized properly).
1818
(nielsdos)
1919

20+
- EXIF:
21+
. Fixed bug GH-16409 (Segfault in exif_thumbnail when not dealing with a
22+
real file). (nielsdos, cmb)
23+
2024
- GD:
2125
. Fixed bug GH-16334 (imageaffine overflow on matrix elements).
2226
(David Carlier)

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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
GH-16409 (Segfault in exif_thumbnail when not dealing with a real file)
3+
--EXTENSIONS--
4+
exif
5+
--FILE--
6+
<?php
7+
$stream = popen('echo 1', 'r');
8+
var_dump(exif_thumbnail($stream, $pipes, $stream, $pipes));
9+
?>
10+
--EXPECTF--
11+
Warning: exif_thumbnail(): File too small (0) in %s on line %d
12+
bool(false)%A

0 commit comments

Comments
 (0)