summaryrefslogtreecommitdiff
path: root/src/regex
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2018-10-11 14:27:15 -0400
committerRich Felker <dalias@aerifal.cx>2018-10-11 14:27:15 -0400
commit09a805a62307307230a31125425d0c2b0b6f332e (patch)
tree7d5d333ca32f863be3cff411957b07578efa3ac7 /src/regex
parente2552581bc004f7dc5ee9ac220cad8abeae19bba (diff)
downloadmusl-09a805a62307307230a31125425d0c2b0b6f332e.tar.gz
fix redundant computations of strlen in glob append function
len was already passed as an argument, so don't use strcat, and use memcpy instead of strcpy.
Diffstat (limited to 'src/regex')
-rw-r--r--src/regex/glob.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/regex/glob.c b/src/regex/glob.c
index 98636295..3e1b034e 100644
--- a/src/regex/glob.c
+++ b/src/regex/glob.c
@@ -41,8 +41,11 @@ static int append(struct match **tail, const char *name, size_t len, int mark)
if (!new) return -1;
(*tail)->next = new;
new->next = NULL;
- strcpy(new->name, name);
- if (mark) strcat(new->name, "/");
+ memcpy(new->name, name, len+1);
+ if (mark) {
+ new->name[len] = '/';
+ new->name[len+1] = 0;
+ }
*tail = new;
return 0;
}