[pacman-dev,2/5] query_fileowner: avoid buffer overflow

Message ID 20170510225457.18270-2-andrew.gregory.8@gmail.com
State Accepted, archived
Headers show
Series [pacman-dev,1/5] alpm_unlock: check handle before dereferencing | expand

Commit Message

Andrew Gregory May 10, 2017, 10:54 p.m. UTC
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
47762ab687959e48acc2de8592fcf3ba3cfa502b.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
---
 src/pacman/query.c | 1 +
 1 file changed, 1 insertion(+)

Patch

diff --git a/src/pacman/query.c b/src/pacman/query.c
index 119764bc..247423fa 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -205,6 +205,7 @@  static int query_fileowner(alpm_list_t *targets)
 			size_t rlen = strlen(rpath);
 			if(rlen + 2 >= PATH_MAX) {
 					pm_printf(ALPM_LOG_ERROR, _("path too long: %s/\n"), rpath);
+					goto targcleanup;
 			}
 			strcat(rpath + rlen, "/");
 		}