aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/whereis
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2019-01-24 18:39:45 +0000
committerStefan Eßer <se@FreeBSD.org>2019-01-24 18:39:45 +0000
commitf5ce14028c19e5e5be61a2b6aa8242fc36cc8e67 (patch)
tree4a7a209ab2f62b4da3940f523704fa98616c0621 /usr.bin/whereis
parentfc24ba59eef56147823b2af4c3af5a71946d007d (diff)
Notes
Diffstat (limited to 'usr.bin/whereis')
-rw-r--r--usr.bin/whereis/whereis.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/usr.bin/whereis/whereis.c b/usr.bin/whereis/whereis.c
index b9b8f7810b79..48426d376181 100644
--- a/usr.bin/whereis/whereis.c
+++ b/usr.bin/whereis/whereis.c
@@ -285,9 +285,9 @@ defaults(void)
bindirs[nele] = NULL;
if ((cp = getenv("PATH")) != NULL) {
/* don't destroy the original environment... */
- if ((b = malloc(strlen(cp) + 1)) == NULL)
+ b = strdup(cp);
+ if (b == NULL)
abort();
- strcpy(b, cp);
decolonify(b, &bindirs, &nele);
}
}
@@ -301,18 +301,18 @@ defaults(void)
err(EX_OSERR, "error processing manpath results");
if ((b = strchr(buf, '\n')) != NULL)
*b = '\0';
- if ((b = malloc(strlen(buf) + 1)) == NULL)
+ b = strdup(buf);
+ if (b == NULL)
abort();
- strcpy(b, buf);
nele = 0;
decolonify(b, &mandirs, &nele);
}
/* -s defaults to precompiled list, plus subdirs of /usr/ports */
if (!sourcedirs) {
- if ((b = malloc(strlen(sourcepath) + 1)) == NULL)
+ b = strdup(sourcepath);
+ if (b == NULL)
abort();
- strcpy(b, sourcepath);
nele = 0;
decolonify(b, &sourcedirs, &nele);
@@ -523,11 +523,9 @@ main(int argc, char **argv)
* man -w found plain source
* page, use it.
*/
- s = strlen(buf);
- cp2 = malloc(s + 1);
+ cp2 = strdup(buf);
if (cp2 == NULL)
abort();
- strcpy(cp2, buf);
}
if (man == NULL) {