diff options
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -1112,15 +1112,16 @@ static char * join_path(const char *path, int dirsep, const char *name) { long len = strlen(path); - char *buf = GLOB_ALLOC_N(char, len+strlen(name)+(dirsep?1:0)+1); + long len2 = strlen(name)+(dirsep?1:0)+1; + char *buf = GLOB_ALLOC_N(char, len+len2); if (!buf) return 0; memcpy(buf, path, len); if (dirsep) { - strcpy(buf+len, "/"); - len++; + buf[len++] = '/'; } - strcpy(buf+len, name); + buf[len] = '\0'; + strlcat(buf+len, name, len2); return buf; } @@ -1301,12 +1302,13 @@ glob_helper( if (*cur) { char *buf; char *name; - name = GLOB_ALLOC_N(char, strlen((*cur)->str) + 1); + size_t len = strlen((*cur)->str) + 1; + name = GLOB_ALLOC_N(char, len); if (!name) { status = -1; break; } - strcpy(name, (*cur)->str); + memcpy(name, (*cur)->str, len); if (escape) remove_backslashes(name, enc); new_beg = new_end = GLOB_ALLOC_N(struct glob_pattern *, end - beg); |