projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e255258
)
fix redundant computations of strlen in glob append function
author
Rich Felker
<dalias@aerifal.cx>
Thu, 11 Oct 2018 18:27:15 +0000
(14:27 -0400)
committer
Rich Felker
<dalias@aerifal.cx>
Thu, 11 Oct 2018 18:27:15 +0000
(14:27 -0400)
len was already passed as an argument, so don't use strcat, and use
memcpy instead of strcpy.
src/regex/glob.c
patch
|
blob
|
history
diff --git
a/src/regex/glob.c
b/src/regex/glob.c
index 98636295ee1105db11621a7e1fa4fbe0233af567..3e1b034ee775c7dee54515b503b0521e769ddd3e 100644
(file)
--- 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;
}