gfileutils: Correctly reset start value when canonicalising paths
If a path starts with more than two slashes, the start
value was
previously incorrect:
- 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. - 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 beG_DIR_SEPARATOR
). - At this point, with a string
///usr
,output
points to the second/
; andstart
points to theu
. This is incorrect, asstart
should point to the starting character for output, as per the original call tog_path_skip_root()
. - For paths which subsequently include a
..
, this results in theoutput > start
check in the..
loop below not skipping all the characters of a preceding path component, which is then caught by theG_IS_DIR_SEPARATOR (output[-1])
assertion.
Signed-off-by: Philip Withnall pwithnall@endlessos.org
oss-fuzz#41563