Skip to content

Commit 810c5c7

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix bug #79336
2 parents 0001340 + 0b709e3 commit 810c5c7

File tree

1 file changed

+34
-9
lines changed

1 file changed

+34
-9
lines changed

ext/exif/exif.c

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,7 @@ static signed short php_ifd_get16s(void *value, int motorola_intel)
14501450
}
14511451
/* }}} */
14521452

1453-
/* {{{ php_ifd_get32s
1453+
/* {{{ php_ifd_get32u
14541454
* Convert a 32 bit unsigned value from file's native byte order */
14551455
static unsigned php_ifd_get32u(void *void_value, int motorola_intel)
14561456
{
@@ -1469,6 +1469,33 @@ static unsigned php_ifd_get32u(void *void_value, int motorola_intel)
14691469
}
14701470
/* }}} */
14711471

1472+
/* {{{ php_ifd_get64u
1473+
* Convert a 64 bit unsigned value from file's native byte order */
1474+
static uint64_t php_ifd_get64u(void *void_value, int motorola_intel)
1475+
{
1476+
uchar *value = (uchar *) void_value;
1477+
if (motorola_intel) {
1478+
return ((uint64_t)value[0] << 56)
1479+
| ((uint64_t)value[1] << 48)
1480+
| ((uint64_t)value[2] << 40)
1481+
| ((uint64_t)value[3] << 32)
1482+
| ((uint64_t)value[4] << 24)
1483+
| ((uint64_t)value[5] << 16)
1484+
| ((uint64_t)value[6] << 8 )
1485+
| ((uint64_t)value[7] );
1486+
} else {
1487+
return ((uint64_t)value[7] << 56)
1488+
| ((uint64_t)value[6] << 48)
1489+
| ((uint64_t)value[5] << 40)
1490+
| ((uint64_t)value[4] << 32)
1491+
| ((uint64_t)value[3] << 24)
1492+
| ((uint64_t)value[2] << 16)
1493+
| ((uint64_t)value[1] << 8 )
1494+
| ((uint64_t)value[0] );
1495+
}
1496+
}
1497+
/* }}} */
1498+
14721499
/* {{{ php_ifd_get32u
14731500
* Convert a 32 bit signed value from file's native byte order */
14741501
static unsigned php_ifd_get32s(void *value, int motorola_intel)
@@ -1510,17 +1537,15 @@ static void php_ifd_set32u(char *data, size_t value, int motorola_intel)
15101537
/* }}} */
15111538

15121539
static float php_ifd_get_float(char *data) {
1513-
/* Copy to avoid alignment issues */
1514-
float f;
1515-
memcpy(&f, data, sizeof(float));
1516-
return f;
1540+
union { uint32_t i; float f; } u;
1541+
u.i = php_ifd_get32u(data, 0);
1542+
return u.f;
15171543
}
15181544

15191545
static double php_ifd_get_double(char *data) {
1520-
/* Copy to avoid alignment issues */
1521-
double f;
1522-
memcpy(&f, data, sizeof(double));
1523-
return f;
1546+
union { uint64_t i; double f; } u;
1547+
u.i = php_ifd_get64u(data, 0);
1548+
return u.f;
15241549
}
15251550

15261551
#ifdef EXIF_DEBUG

0 commit comments

Comments
 (0)