1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Fix GH-15552: Signed integer overflow in ext/standard/scanf.c
This commit is contained in:
Christoph M. Becker
2024-09-01 17:25:00 +02:00
3 changed files with 14 additions and 2 deletions

3
NEWS
View File

@@ -27,6 +27,9 @@ PHP NEWS
. Fixed bug GH-15432 (Heap corruption when querying a vector). (cmb,
Kamil Tekiela)
- Standard:
. Fixed bug GH-15552 (Signed integer overflow in ext/standard/scanf.c). (cmb)
- Streams:
. Fixed bug GH-15628 (php_stream_memory_get_buffer() not zero-terminated).
(cmb)

View File

@@ -361,8 +361,7 @@ PHPAPI int ValidateFormat(char *format, int numVars, int *totalSubs)
if (gotSequential) {
goto mixedXPG;
}
objIndex = value - 1;
if ((objIndex < 0) || (numVars && (objIndex >= numVars))) {
if ((value < 1) || (numVars && (value > numVars))) {
goto badIndex;
} else if (numVars == 0) {
/*
@@ -382,6 +381,7 @@ PHPAPI int ValidateFormat(char *format, int numVars, int *totalSubs)
xpgSize = (xpgSize > value) ? xpgSize : value;
}
objIndex = value - 1;
goto xpgCheckDone;
}

View File

@@ -0,0 +1,9 @@
--TEST--
Bug GH-15552 (Signed integer overflow in ext/standard/scanf.c)
--FILE--
<?php
var_dump(sscanf('hello','%2147483648$s'));
?>
--EXPECTF--
Fatal error: Uncaught ValueError: "%n$" argument index out of range in %s:%d
Stack trace:%A