summaryrefslogtreecommitdiffstats
path: root/bin/sh/exec.c
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2013-11-30 21:27:11 +0000
committerjilles <jilles@FreeBSD.org>2013-11-30 21:27:11 +0000
commit1d244d8c4507dc5abd9737693f6701563f3d84cf (patch)
treec17a94fbfcf3043c6d204ab64d6206f30a61de7c /bin/sh/exec.c
parentbcd91960e57f31a95cde119b0a51024463a4b4cc (diff)
downloadFreeBSD-src-1d244d8c4507dc5abd9737693f6701563f3d84cf.zip
FreeBSD-src-1d244d8c4507dc5abd9737693f6701563f3d84cf.tar.gz
sh: Prefer memcpy() to strcpy() in most cases. Remove the scopy macro.
Diffstat (limited to 'bin/sh/exec.c')
-rw-r--r--bin/sh/exec.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/bin/sh/exec.c b/bin/sh/exec.c
index e2dd053..5f30ec6 100644
--- a/bin/sh/exec.c
+++ b/bin/sh/exec.c
@@ -187,14 +187,15 @@ padvance(const char **path, const char *name)
{
const char *p, *start;
char *q;
- size_t len;
+ size_t len, namelen;
if (*path == NULL)
return NULL;
start = *path;
for (p = start; *p && *p != ':' && *p != '%'; p++)
; /* nothing */
- len = p - start + strlen(name) + 2; /* "2" is for '/' and '\0' */
+ namelen = strlen(name);
+ len = p - start + namelen + 2; /* "2" is for '/' and '\0' */
STARTSTACKSTR(q);
CHECKSTRSPACE(len, q);
if (p != start) {
@@ -202,7 +203,7 @@ padvance(const char **path, const char *name)
q += p - start;
*q++ = '/';
}
- strcpy(q, name);
+ memcpy(q, name, namelen + 1);
pathopt = NULL;
if (*p == '%') {
pathopt = ++p;
@@ -527,6 +528,7 @@ cmdlookup(const char *name, int add)
const char *p;
struct tblentry *cmdp;
struct tblentry **pp;
+ size_t len;
p = name;
hashval = *p << 4;
@@ -541,11 +543,11 @@ cmdlookup(const char *name, int add)
}
if (add && cmdp == NULL) {
INTOFF;
- cmdp = *pp = ckmalloc(sizeof (struct tblentry)
- + strlen(name) + 1);
+ len = strlen(name);
+ cmdp = *pp = ckmalloc(sizeof (struct tblentry) + len + 1);
cmdp->next = NULL;
cmdp->cmdtype = CMDUNKNOWN;
- strcpy(cmdp->cmdname, name);
+ memcpy(cmdp->cmdname, name, len + 1);
INTON;
}
lastcmdentry = pp;
OpenPOWER on IntegriCloud