aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar sin <sin@2f30.org>2014-11-14 12:50:41 +0000
committerGravatar sin <sin@2f30.org>2014-11-14 12:50:41 +0000
commit3639f1bbb4547f14ec792b311f117aef27dcc7f9 (patch)
treed9c4ed0805243bbd4fc607b0e29a01468cd152b4
parent89d0dc35ee86838b781b37d93172426cf5251609 (diff)
downloadnnn-3639f1bbb4547f14ec792b311f117aef27dcc7f9.tar.gz
Just use xstrdup() in makepath()
-rw-r--r--noice.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/noice.c b/noice.c
index f52e910..d0b0094 100644
--- a/noice.c
+++ b/noice.c
@@ -452,24 +452,23 @@ dentfree(struct entry *dents, int n)
char *
makepath(char *dir, char *name)
{
- char *path;
+ char path[PATH_MAX];
/* Handle absolute path */
if (name[0] == '/') {
- path = xstrdup(name);
+ strlcpy(path, name, sizeof(path));
} else {
- path = xmalloc(PATH_MAX);
/* Handle root case */
if (strcmp(dir, "/") == 0) {
- strlcpy(path, "/", PATH_MAX);
- strlcat(path, name, PATH_MAX);
+ strlcpy(path, "/", sizeof(path));
+ strlcat(path, name, sizeof(path));
} else {
- strlcpy(path, dir, PATH_MAX);
- strlcat(path, "/", PATH_MAX);
- strlcat(path, name, PATH_MAX);
+ strlcpy(path, dir, sizeof(path));
+ strlcat(path, "/", sizeof(path));
+ strlcat(path, name, sizeof(path));
}
}
- return path;
+ return xstrdup(path);
}
/* Return the position of the matching entry or 0 otherwise */