Skip to content

Commit

Permalink
Remove duplicated length check in exif and
Browse files Browse the repository at this point in the history
remove always false condition from exif

The latter condition will never trigger because otherwise the do-while loop
wouldn't have exited.

Close GH-10402
  • Loading branch information
nielsdos authored and devnexen committed Jan 22, 2023
1 parent 23dab38 commit f4dd35e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ PHP NEWS
. Implement GH-10217 (Use strlen() for determining the class_name length).
(Dennis Buteyn)

- Exif:
. Removed unneeded codepaths in exif_process_TIFF_in_JPEG(). (nielsdos)

- Fileinfo:
. Upgrade bundled libmagic to 5.43. (Anatol)

Expand Down
11 changes: 0 additions & 11 deletions ext/exif/exif.c
Original file line number Diff line number Diff line change
Expand Up @@ -3679,11 +3679,6 @@ static void exif_process_TIFF_in_JPEG(image_info_type *ImageInfo, char *CharBuf,
return;
}

if (length < 2) {
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Missing TIFF alignment marker");
return;
}

/* set the thumbnail stuff to nothing so we can test to see if they get set up */
if (memcmp(CharBuf, "II", 2) == 0) {
ImageInfo->motorola_intel = 0;
Expand Down Expand Up @@ -3810,12 +3805,6 @@ static bool exif_scan_JPEG_header(image_info_type *ImageInfo)

fpos = php_stream_tell(ImageInfo->infile);

if (marker == 0xff) {
/* 0xff is legal padding, but if we get that many, something's wrong. */
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "To many padding bytes");
return false;
}

/* Read the length of the section. */
if ((lh = php_stream_getc(ImageInfo->infile)) == (unsigned int)EOF) {
EXIF_ERRLOG_CORRUPT(ImageInfo)
Expand Down

0 comments on commit f4dd35e

Please # to comment.