Hi,

Just a couple of warnings fixed.

Thanks,
sin
>From f0b0a8dc84444686963d18eb781782ba5d9bde9a Mon Sep 17 00:00:00 2001
From: sin <s...@2f30.org>
Date: Thu, 15 Aug 2013 10:25:29 +0100
Subject: [PATCH] Fix warnings about strcpy() etc. on OpenBSD

---
 ls.c            | 2 +-
 split.c         | 2 +-
 util/afgets.c   | 2 +-
 util/getlines.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/ls.c b/ls.c
index f61d7c5..cd6cfe8 100644
--- a/ls.c
+++ b/ls.c
@@ -137,7 +137,7 @@ lsdir(const char *path)
                                eprintf("realloc:");
                        if(!(p = malloc(strlen(d->d_name)+1)))
                                eprintf("malloc:");
-                       strcpy(p, d->d_name);
+                       snprintf(p, strlen(d->d_name)+1, "%s", d->d_name);
                        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
@@ -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..836b7a5 100644
--- a/util/afgets.c
+++ b/util/afgets.c
@@ -17,7 +17,7 @@ afgets(char **p, size_t *size, FILE *fp)
                if(len+1 > *size && !(*p = realloc(*p, len+1)))
                        eprintf("realloc:");
 
-               strcpy(&(*p)[len-n], buf);
+               snprintf(&(*p)[len-n], n+1, "%s", buf);
 
                if(buf[n-1] == '\n' || feof(fp))
                        break;
diff --git a/util/getlines.c b/util/getlines.c
index d3152ec..c5b4b71 100644
--- a/util/getlines.c
+++ b/util/getlines.c
@@ -22,7 +22,7 @@ getlines(FILE *fp, struct linebuf *b)
                }
                if(!(b->lines[b->nlines-1] = malloc(strlen(line)+1)))
                        eprintf("malloc:");
-               strcpy(b->lines[b->nlines-1], line);
+               snprintf(b->lines[b->nlines-1], strlen(line)+1, "%s", line);
        }
        free(line);
 }
-- 
1.8.2.3

Reply via email to