query_fileowner: avoid buffer overflow

Copying a string into a buffer that  has just been determined to not be
able to hold it is obviously incorrect.  The actual error handling
appears to have been unintentionally removed in
47762ab687.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Andrew Gregory 2017-05-10 18:54:54 -04:00 committed by Allan McRae
parent 1bc79cb9a5
commit a2b776f6c9

View file

@ -204,6 +204,7 @@ static int query_fileowner(alpm_list_t *targets)
size_t rlen = strlen(rpath); size_t rlen = strlen(rpath);
if(rlen + 2 >= PATH_MAX) { if(rlen + 2 >= PATH_MAX) {
pm_printf(ALPM_LOG_ERROR, _("path too long: %s/\n"), rpath); pm_printf(ALPM_LOG_ERROR, _("path too long: %s/\n"), rpath);
goto targcleanup;
} }
strcat(rpath + rlen, "/"); strcat(rpath + rlen, "/");
} }