Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
mkdirat_p: fix invalid free
Ralf Hubert committed 8 years ago
commit 0be3f5e7f1651bf4c8cb7b1f624a249bb2182383
parent 0213e99
1 file changed +4 -4
modified libpkg/utils.c
@@ -760,9 +760,9 @@ bool
mkdirat_p(int fd, const char *path)
{
	const char *next;
-
	char *walk, pathdone[MAXPATHLEN];
+
	char *walk, *walkorig, pathdone[MAXPATHLEN];

-
	walk = xstrdup(path);
+
	walk = walkorig = xstrdup(path);
	pathdone[0] = '\0';

	while ((next = strsep(&walk, "/")) != NULL) {
@@ -775,11 +775,11 @@ mkdirat_p(int fd, const char *path)
				continue;
			}
			pkg_errno("Fail to create /%s", pathdone);
-
			free(walk);
+
			free(walkorig);
			return (false);
		}
		strlcat(pathdone, "/", sizeof(pathdone));
	}
-
	free(walk);
+
	free(walkorig);
	return (true);
}