Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ext/standard/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "php.h"
#include <stdio.h>
#include <stdint.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
Expand Down Expand Up @@ -1520,7 +1521,16 @@ static void php_getimagesize_from_stream(php_stream *stream, char *input, zval *
break;
}

#if SIZEOF_ZEND_LONG == 4
if (result &&
result->width <= INT32_MAX &&
result->height <= INT32_MAX &&
result->bits <= INT32_MAX &&
result->channels <= INT32_MAX)
{
Comment on lines +1525 to +1530
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can check whether it's a 32-bit build and use conditional compilation accordingly.

Suggested change
if (result &&
result->width <= INT32_MAX &&
result->height <= INT32_MAX &&
result->bits <= INT32_MAX &&
result->channels <= INT32_MAX)
{
#if SIZEOF_ZEND_LONG == 4
if (result &&
result->width <= INT32_MAX &&
result->height <= INT32_MAX &&
result->bits <= INT32_MAX &&
result->channels <= INT32_MAX)
{
#else
if (result) {
#endif

#else
if (result) {
#endif
char temp[MAX_LENGTH_OF_LONG * 2 + sizeof("width=\"\" height=\"\"")];
array_init(return_value);
add_index_long(return_value, 0, result->width);
Expand Down