Skip to content

integer overflow in ImageString #20622

@chongwick

Description

@chongwick

Description

The following code:

<?php
$im = imagecreate(100, 30);

$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);

imagestring($im, 5, 2147483647, 0, 'Hello world!', $textcolor);

Resulted in this output:

/home/w023dtc/nightly_php/php-src/ext/gd/gd.c:3020:7: runtime error: signed integer overflow: 2147483647 + 9 cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/w023dtc/nightly_php/php-src/ext/gd/gd.c:3020:7

PHP Version

nightly

Operating System

ubuntu 22.04

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions