1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00
Files
archived-php-src/tests/basic
Niels Dossche aab784263d Fix GH-16998: UBSAN warning in rfc1867
The "else branch" of `next_line` can reset the `buf_begin` field to
NULL, causing the next invocation to pass NULL to `memchr` with a 0
length. When UBSAN is enabled this causes an UBSAN abort. Real world
impact is likely none because of the 0 length.

To fix this, don't set the pointer to NULL, which means that the
`memchr` will return NULL and since
`self->bytes_in_buffer < self->bufsize` we return NULL and request more
data through `fill_buffer`. That function will reset `buf_begin` and
`bytes_in_buffer` so that the next invocation works fine.

I chose this solution so we have an invariant that `buf_begin` is never
NULL, which makes reasoning easier. An alternative solution is keeping
the NULLing of `buf_begin` and add an extra check at the top of
`next_line`, but I didn't like special casing this.

Closes GH-17000.
2024-12-01 10:59:30 +01:00
..
2018-10-14 19:45:12 +02:00
2018-10-14 19:45:12 +02:00
2018-10-14 19:45:12 +02:00
2020-02-03 22:52:20 +01:00
2020-02-03 22:52:20 +01:00
2018-10-14 19:45:12 +02:00
2018-10-14 19:45:12 +02:00
2018-10-14 19:46:15 +02:00
2018-10-14 19:46:15 +02:00
2018-10-14 19:46:15 +02:00
2018-10-14 19:46:15 +02:00
2018-10-14 19:46:15 +02:00
2018-10-14 19:46:15 +02:00
2020-09-26 23:47:04 -07:00
2020-09-26 23:47:04 -07:00
2022-07-18 23:19:59 +01:00
2021-04-13 12:09:37 +02:00
2021-06-11 11:57:42 +02:00
2020-02-03 22:52:20 +01:00
2019-05-27 10:51:53 +02:00
2019-12-05 11:19:23 +01:00
2019-12-05 11:19:23 +01:00
2019-12-05 11:19:23 +01:00
2019-12-05 11:19:23 +01:00
2019-12-05 11:19:23 +01:00
2019-12-05 11:19:23 +01:00