mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 14:06:15 +01:00
tests: Fix 1-byte overread in data-input-stream tests
Commit 760a6f647
rearranged how the lengths are calculated for the test
data and added `escape_data_string()` so they could be printed safely.
Unfortunately there was a miscount in the length of the first test
vector in `test_read_upto()`: there are 31 bytes in the string literal,
plus one nul terminator which is added by the compiler. The quoted
string length was 32 bytes. This should be fine (explicitly including
the nul delimiter), but then `escape_data_string()` adds another byte to
the length because it assumes the nul delimiter has *not* been included
in the count.
Changing the string length from 32 to 31 breaks the tests, as the final
component of the data is then the wrong length, so add an additional
explicit nul byte to the string literal so that it matches the length.
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
parent
e3e936f7ba
commit
50ccb04c71
@ -314,7 +314,7 @@ test_read_upto (void)
|
||||
const char *data_sep;
|
||||
size_t data_sep_len;
|
||||
} vectors[] = {
|
||||
{ 10, " part1 # part2 $ part3 \0 part4 ", 32, 7, "#$\0^", 4 },
|
||||
{ 10, " part1 # part2 $ part3 \0 part4 \0", 32, 7, "#$\0^", 4 },
|
||||
{ 20, "{\"key\": \"value\"}\0", 17, 16, "\0", 1 },
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user