Skip to content

Commit 363bb03

Browse files
committed
We need to check for the length here too, or we crash and no one likes that! :(
1 parent 969eb83 commit 363bb03

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ext/exif/exif.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4312,6 +4312,8 @@ static int exif_read_from_stream(image_info_type *ImageInfo, php_stream *stream,
43124312
int ret;
43134313
zend_stat_t st;
43144314

4315+
php_printf("exif_read_from_stream");
4316+
43154317
/* Start with an empty image information structure. */
43164318
memset(ImageInfo, 0, sizeof(*ImageInfo));
43174319

@@ -4375,6 +4377,8 @@ static int exif_read_from_file(image_info_type *ImageInfo, char *FileName, int r
43754377
int ret;
43764378
php_stream *stream;
43774379

4380+
php_printf("exif_read_from_file");
4381+
43784382
stream = php_stream_open_wrapper(FileName, "rb", STREAM_MUST_SEEK | IGNORE_PATH, NULL);
43794383

43804384
if (!stream) {
@@ -4454,6 +4458,12 @@ PHP_FUNCTION(exif_read_data)
44544458
} else {
44554459
convert_to_string(stream);
44564460

4461+
if (!Z_STRLEN_P(stream)) {
4462+
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_WARNING, "Filename cannot be empty");
4463+
4464+
RETURN_FALSE;
4465+
}
4466+
44574467
ret = exif_read_from_file(&ImageInfo, Z_STRVAL_P(stream), read_thumbnail, read_all);
44584468
}
44594469

@@ -4618,6 +4628,12 @@ PHP_FUNCTION(exif_thumbnail)
46184628
} else {
46194629
convert_to_string(stream);
46204630

4631+
if (!Z_STRLEN_P(stream)) {
4632+
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_WARNING, "Filename cannot be empty");
4633+
4634+
RETURN_FALSE;
4635+
}
4636+
46214637
ret = exif_read_from_file(&ImageInfo, Z_STRVAL_P(stream), 1, 0);
46224638
}
46234639

0 commit comments

Comments
 (0)