mirror of
https://git.savannah.gnu.org/git/make.git
synced 2024-11-24 12:19:02 +00:00
Fix unlikely pointer overflow in abspath
* src/function.c (abspath): len is now ptrdiff_t, to avoid GCC warning about comparing signed to unsigned. It really is a pointer difference, after all. Rejigger comparision to avoid undefined behavior if dest + len is an invalid pointer.
This commit is contained in:
parent
c23a7e6232
commit
bba4427b5d
1 changed files with 2 additions and 2 deletions
|
@ -2119,7 +2119,7 @@ abspath (const char *name, char *apath)
|
|||
|
||||
for (start = end = name; *start != '\0'; start = end)
|
||||
{
|
||||
size_t len;
|
||||
ptrdiff_t len;
|
||||
|
||||
/* Skip sequence of multiple path-separators. */
|
||||
while (ISDIRSEP (*start))
|
||||
|
@ -2147,7 +2147,7 @@ abspath (const char *name, char *apath)
|
|||
if (! ISDIRSEP (dest[-1]))
|
||||
*dest++ = '/';
|
||||
|
||||
if (dest + len >= apath_limit)
|
||||
if (apath_limit - dest <= len)
|
||||
return NULL;
|
||||
|
||||
dest = mempcpy (dest, start, len);
|
||||
|
|
Loading…
Reference in a new issue