1
0
mirror of https://github.com/php/php-src.git synced 2026-04-10 09:33:06 +02:00
Files
archived-php-src/ext/standard
Niels Dossche 87862835e2 Fix undefined behaviour in unpack()
atoi()'s return value is actually undefined when an underflow or
overflow occurs. For example on 32-bit on my system the overflow test
which inputs "h2147483648" results in repetitions==2147483647 and on
64-bit this gives repetitions==-2147483648. The reason the test works on
32-bit is because there's a second undefined behaviour problem:
in case 'h' when repetitions==2147483647, we add 1 and divide by 2.
This is signed-wrap undefined behaviour and accidentally triggers the
overflow check like we wanted to.

Avoid all this trouble and use strtol with explicit error checking.

This also fixes a semantic bug where repetitions==INT_MAX would result
in the overflow check to trigger, even though there is no overflow.

Closes GH-10943.
2023-03-28 22:43:27 +02:00
..
2023-03-28 22:43:27 +02:00
2021-05-06 12:16:35 +02:00
2021-05-06 12:16:35 +02:00
2022-07-15 12:48:09 +01:00
2020-10-26 11:06:10 +01:00
2020-06-17 13:04:01 +00:00
2020-04-14 15:16:26 +00:00
2023-02-12 21:33:39 -07:00
2021-05-06 12:16:35 +02:00
2021-05-06 12:16:35 +02:00
2021-08-19 10:39:23 +02:00
2021-08-19 10:39:23 +02:00
2021-08-19 10:39:23 +02:00
2021-05-06 12:16:35 +02:00
2020-05-14 13:35:12 +02:00
2021-08-30 18:55:16 +02:00
2021-05-06 12:16:35 +02:00
2021-05-06 12:16:35 +02:00
2022-03-04 16:07:54 +01:00
2021-07-06 12:03:55 +02:00
2021-05-06 12:16:35 +02:00
2021-05-06 12:16:35 +02:00
2021-05-06 12:16:35 +02:00
2021-05-06 12:16:35 +02:00
2021-05-06 12:16:35 +02:00
2021-05-06 12:16:35 +02:00
2021-05-06 12:16:35 +02:00
2021-05-06 12:16:35 +02:00
2021-07-16 10:07:35 +02:00
2021-05-06 12:16:35 +02:00
2021-06-29 11:30:26 +02:00
2021-05-06 12:16:35 +02:00
2021-05-06 12:16:35 +02:00
2022-01-17 22:32:37 +01:00
2021-05-06 12:16:35 +02:00
2021-05-06 12:16:35 +02:00
2021-05-06 12:16:35 +02:00
2021-06-11 09:34:03 +02:00
2023-03-28 22:43:27 +02:00
2021-05-06 12:16:35 +02:00
2021-07-20 15:14:08 +02:00
2021-11-15 10:00:55 +01:00
2021-05-06 12:16:35 +02:00
2022-07-15 12:48:09 +01:00
2021-05-06 12:16:35 +02:00
2021-05-06 12:16:35 +02:00
2021-05-06 12:16:35 +02:00
2022-06-19 20:09:37 +01:00
2021-05-06 12:16:35 +02:00
2021-05-06 12:16:35 +02:00
2021-08-01 18:03:30 +01:00
2021-05-06 12:16:35 +02:00