mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
Ticket #3437: (custom_canonicalize_pathname): fix heap-buffer-overflow.
Only use strncmp when path has enough room (greater then url_delim_len size). Overflow happen when path = './'. (Found by AddressSanitizer.) Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
c9b07317c3
commit
4821259d85
@ -893,7 +893,7 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
|
||||
p = lpath + strlen (lpath) - 1;
|
||||
while (p > lpath && IS_PATH_SEP (*p))
|
||||
{
|
||||
if (p >= lpath - (url_delim_len + 1)
|
||||
if (p >= lpath + url_delim_len - 1
|
||||
&& strncmp (p - url_delim_len + 1, VFS_PATH_URL_DELIMITER, url_delim_len) == 0)
|
||||
break;
|
||||
*p-- = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user