--- ls.c | 5 +++-- split.c | 2 +- util/afgets.c | 3 ++- util/getlines.c | 5 +++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ls.c b/ls.c index f61d7c5..e3a440f 100644 --- a/ls.c +++ b/ls.c _AT_@ -112,6 +112,7 @@ lsdir(const char *path) struct dirent *d; DIR *dp; Entry ent, *ents = NULL; + size_t sz; cwd = agetcwd(); if(!(dp = opendir(path))) _AT_@ -135,9 +136,9 @@ lsdir(const char *path) } else { if(!(ents = realloc(ents, ++n * sizeof *ents))) eprintf("realloc:"); - if(!(p = malloc(strlen(d->d_name)+1))) + if(!(p = malloc((sz = strlen(d->d_name)+1)))) eprintf("malloc:"); - strcpy(p, d->d_name); + memcpy(p, d->d_name, sz); mkent(&ents[n-1], p, tflag || lflag); } } diff --git a/split.c b/split.c index cf22125..633c02e 100644 --- a/split.c +++ b/split.c _AT_@ -74,7 +74,7 @@ main(int argc, char **argv) plen = strlen(prefix); if(plen+slen > NAME_MAX) eprintf("split: names cannot exceed %d bytes", NAME_MAX); - strcpy(name, prefix); + snprintf(name, sizeof(name), "%s", prefix); if(file && strcmp(file, "-") != 0) { in = fopen(file, "r"); diff --git a/util/afgets.c b/util/afgets.c index e1d719d..4b4ffe2 100644 --- a/util/afgets.c +++ b/util/afgets.c _AT_@ -17,7 +17,8 @@ afgets(char **p, size_t *size, FILE *fp) if(len+1 > *size && !(*p = realloc(*p, len+1))) eprintf("realloc:"); - strcpy(&(*p)[len-n], buf); + memcpy(&(*p)[len-n], buf, n); + (*p)[len] = '\0'; if(buf[n-1] == '\n' || feof(fp)) break; diff --git a/util/getlines.c b/util/getlines.c index d3152ec..f1c3453 100644 --- a/util/getlines.c +++ b/util/getlines.c _AT_@ -11,6 +11,7 @@ getlines(FILE *fp, struct linebuf *b) { char *line = NULL, **nline; size_t size = 0; + size_t linelen; while(afgets(&line, &size, fp)) { if(++b->nlines > b->capacity) { _AT_@ -20,9 +21,9 @@ getlines(FILE *fp, struct linebuf *b) eprintf("realloc:"); b->lines = nline; } - if(!(b->lines[b->nlines-1] = malloc(strlen(line)+1))) + if(!(b->lines[b->nlines-1] = malloc((linelen = strlen(line)+1)))) eprintf("malloc:"); - strcpy(b->lines[b->nlines-1], line); + memcpy(b->lines[b->nlines-1], line, linelen); } free(line); } -- 1.8.2.3 --sm4nu43k4a2Rpi4c Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0003-Add-not-implemented-errors-for-unimplemented-flags.patch"Received on Mon Sep 17 2001 - 00:00:00 CEST
This archive was generated by hypermail 2.3.0 : Thu Aug 15 2013 - 14:12:02 CEST