mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-28 00:16:15 +01:00
fc25f8d7ef
If a path starts with more than two slashes, the `start` value was previously incorrect: 1. As per the `g_path_skip_root()` call, `start` was set to point to after the final initial slash. For a path with three initial slashes, this is the character after the third slash. 2. The canonicalisation loop to find the first dir separator sets `output` to point to the character after the first slash (and it overwrites the first slash to be `G_DIR_SEPARATOR`). 3. At this point, with a string `///usr`, `output` points to the second `/`; and `start` points to the `u`. This is incorrect, as `start` should point to the starting character for output, as per the original call to `g_path_skip_root()`. 4. For paths which subsequently include a `..`, this results in the `output > start` check in the `..` loop below not skipping all the characters of a preceding path component, which is then caught by the `G_IS_DIR_SEPARATOR (output[-1])` assertion. Fix this by resetting `start` to `output` after finding the final slash to keep in the output, but before starting the main parsing loop. Relatedly, split `start` into two variables: `after_root` and `output_start`, since the variable actually has two roles in the two parts of the function. Includes a test. This commit is heavily based on suggestions by Sebastian Wilhemi and Sebastian Dröge. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> oss-fuzz#41563 |
||
---|---|---|
.. | ||
collate | ||
gobject | ||
refcount | ||
assert-msg-test.c | ||
assert-msg-test.gdb | ||
casefold.txt | ||
casemap.txt | ||
child-test.c | ||
completion-test.c | ||
cxx-test.cpp | ||
datetime.c | ||
dirname-test.c | ||
env-test.c | ||
file-test.c | ||
gen-casefold-txt.py | ||
gen-casemap-txt.py | ||
gio-test.c | ||
iochannel-test-infile | ||
iochannel-test.c | ||
libmoduletestplugin_a.c | ||
libmoduletestplugin_b.c | ||
mainloop-test.c | ||
mapping-test.c | ||
memchunks.c | ||
meson.build | ||
module-test.c | ||
onceinit.c | ||
relation-test.c | ||
run-assert-msg-test.sh | ||
run-collate-tests.sh | ||
slice-color.c | ||
slice-concurrent.c | ||
slice-test.c | ||
slice-threadinit.c | ||
spawn-test-win32-gui.c | ||
spawn-test.c | ||
testgdate.c | ||
testgdateparser.c | ||
testglib.c | ||
thread-test.c | ||
threadpool-test.c | ||
timeloop-basic.c | ||
timeloop.c | ||
type-test.c | ||
unicode-caseconv.c | ||
unicode-collate.c | ||
unicode-encoding.c | ||
unicode-normalize.c | ||
utf8.txt |