From e5774555cf657776366141bbd82192ffb38d5c49 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 27 Dec 2008 22:56:47 +0100 Subject: [PATCH] xbps-bin: simplify sanitize_localpath(). --HG-- extra : convert_revision : 223334822b80c6b11e63f1a34e7bfadb9115d5b9 --- bin/xbps-bin.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/bin/xbps-bin.c b/bin/xbps-bin.c index b98c94d871..1b8f912235 100644 --- a/bin/xbps-bin.c +++ b/bin/xbps-bin.c @@ -130,6 +130,7 @@ static bool sanitize_localpath(char *buf, const char *path) { char *dirnp, *basenp, *dir, *base, *tmp; + bool rv = false; dir = strdup(path); if (dir == NULL) @@ -143,29 +144,27 @@ sanitize_localpath(char *buf, const char *path) dirnp = dirname(dir); if (strcmp(dirnp, ".") == 0) - goto error; + goto out; basenp = basename(base); if (strcmp(basenp, base) == 0) - goto error; + goto out; tmp = strncpy(buf, dirnp, PATH_MAX - 1); if (sizeof(*tmp) >= PATH_MAX) - goto error; + goto out; buf[strlen(buf) + 1] = '\0'; if (strcmp(dirnp, "/")) strncat(buf, "/", 1); strncat(buf, basenp, PATH_MAX - strlen(buf) - 1); + rv = true; + +out: free(dir); free(base); - return true; - -error: - free(base); - free(dir); - return false; + return rv; } int