[hackers] [sbase] Fix some warnings about strcpy() etc. on OpenBSD || sin

From: <git_AT_suckless.org>
Date: Sat, 05 Oct 2013 16:29:15 +0200

commit 582511d57b4970a1411d2b8d81b7af6d64978225
Author: sin <sin_AT_2f30.org>
Date: Thu Aug 15 12:34:38 2013 +0100

    Fix some warnings about strcpy() etc. on OpenBSD

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/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] = '
Received on Sat Oct 05 2013 - 16:29:15 CEST

This archive was generated by hypermail 2.3.0 : Sat Oct 05 2013 - 16:36:16 CEST