Commit graph

14 commits

Author SHA1 Message Date
Daniel Eklöf
2eaa7beba1
uri-parse: fix out-of-bounds read with malformed %-encoded content
If the input URI ends with a trailing '%' (or a trailing '%N'), we
read outside the provided buffer.

On NULL terminated input, this happened to work out since we'd
correctly detect an invalid %-sequence as soon as we read the NULL
terminator.

On input that is not NULL terminated, we're out of luck.

This patch fixes this by also checking we have enough input left to
even _try_ to read the %-digits.

Also add unit tests for this particular case.

Closes #2353
2026-05-22 11:00:48 +02:00
Daniel Eklöf
5335cec322
uri-parse: add a bunch of unit tests 2026-05-22 10:49:22 +02:00
Daniel Eklöf
43566b655f
uri: check 'scheme' is non-null before de-referencing it 2026-05-11 13:37:53 +02:00
Daniel Eklöf
d68da27a7f
uri: skip query/fragment parsing when dealing with file:// URIs
Also, ignore invalid query/fragments (i.e. if the fragment comes
before the query).

Closes #1840
2024-10-23 08:47:21 +02:00
Craig Barnes
e0f3703ae6
util: add streq() function and use in place of strcmp(...) == 0 2024-02-05 12:09:52 +01:00
Daniel Eklöf
1c16e4a575
Tag a couple variables with UNUSED, to fix warnings with clang-15
Closes #1278
2023-02-12 19:09:48 +01:00
Daniel Eklöf
1a91cbecc7
uri: move hex2nibble() to util.h 2022-01-13 13:42:11 +01:00
Daniel Eklöf
1a755d0da2
uri: hostname_is_localhost(): don’t crash if hostname == NULL 2021-06-19 15:56:39 +02:00
Jan Beich
c531c6bc0e
uri: switch to conservative maximum hostname length
Current maximum is provided by sysconf(_SC_HOST_NAME_MAX) instead.

uri.c:269:20: error: use of undeclared identifier 'HOST_NAME_MAX'
    char this_host[HOST_NAME_MAX];
                   ^
2021-01-21 12:00:02 +01:00
Craig Barnes
22f25a9e4f Print stack trace on assert() failure or when calling fatal_error()
Note: this uses the __sanitizer_print_stack_trace() function from the
AddressSanitizer runtime, so it only works when AddressSanitizer is
in use.
2021-01-16 19:56:33 +00:00
Craig Barnes
b9a7cbf21d uri: rename nibbletohex() function to hex2nibble()
It converts a hex digit to a nibble, not the other way around.
2021-01-04 05:31:19 +00:00
Craig Barnes
d30414b3a3 uri: use nibble2hex() instead of isxdigit(3) to check valid hex digits 2021-01-04 05:25:14 +00:00
Daniel Eklöf
bb43695426
codespell: fix misspelled words 2020-10-28 19:34:49 +01:00
Daniel Eklöf
608cc746ad
uri: add uri_parse() - new function extracts components from an URI 2020-10-28 19:10:44 +01:00