From 9083191e4ba3ba7804ef7c5976a2e1ff76bbf60a Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 19 Feb 2015 11:39:59 +0100 Subject: [PATCH] xbps_symlink_target: double free in rootdir == '/' case. --- lib/util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/util.c b/lib/util.c index ac395320..197d004b 100644 --- a/lib/util.c +++ b/lib/util.c @@ -503,12 +503,13 @@ xbps_symlink_target(struct xbps_handle *xhp, const char *path, const char *tgt) if (res == NULL) { if (strcmp(xhp->rootdir, "/") == 0) res = p; - else + else { res = strdup(p + strlen(xhp->rootdir)); + free(p); + } } assert(res); free(lnk); - free(p); } else { /* absolute */ res = lnk;