Skip to content

Commit 4e70d41

Browse files
committed
exif/heic: Fix bound check in loop
The loop checks against `p` but increases `p2`. I don't see the point of having 2 separate variables, so use `p` instead to correct the bounds check and simplify the code in the process.
1 parent 4123b8e commit 4e70d41

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

ext/exif/exif.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4308,7 +4308,7 @@ static int exif_isobmff_parse_box(unsigned char *buf, isobmff_box_type *box)
43084308
static void exif_isobmff_parse_meta(unsigned char *data, unsigned char *end, isobmff_item_pos_type *pos)
43094309
{
43104310
isobmff_box_type box, item;
4311-
unsigned char *box_offset, *p, *p2;
4311+
unsigned char *box_offset, *p;
43124312
int header_size, exif_id = -1, version, item_count, i;
43134313

43144314
size_t remain;
@@ -4367,10 +4367,10 @@ static void exif_isobmff_parse_meta(unsigned char *data, unsigned char *end, iso
43674367
ADVANCE(4);
43684368
item_count = php_ifd_get32u(p - 4, 1);
43694369
}
4370-
for (i = 0, p2 = p; i < item_count && p < end - 16; i++, p2 += 16) {
4371-
if (php_ifd_get16u(p2, 1) == exif_id) {
4372-
pos->offset = php_ifd_get32u(p2 + 8, 1);
4373-
pos->size = php_ifd_get32u(p2 + 12, 1);
4370+
for (i = 0; i < item_count && p < end - 16; i++, p += 16) {
4371+
if (php_ifd_get16u(p, 1) == exif_id) {
4372+
pos->offset = php_ifd_get32u(p + 8, 1);
4373+
pos->size = php_ifd_get32u(p + 12, 1);
43744374
break;
43754375
}
43764376
}

0 commit comments

Comments
 (0)