summaryrefslogtreecommitdiff
path: root/usr.bin/lam/lam.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-04-21 00:42:50 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-04-21 00:42:50 +0000
commit500f45bb07f37d13e0e601d5c1404367b629cfee (patch)
treee8f5ff6eb63ad3da074756438dccf491364f3298 /usr.bin/lam/lam.c
parentc351de439b82bb5b9defad9dc0113cc7b4b716d7 (diff)
Use strlcpy() and snprintf() in favor of inline strcpy() and sprintf().
Based on a diff from krw but this uses the strlcpy() / snprintf() return values. millert tested, krw approved...
Diffstat (limited to 'usr.bin/lam/lam.c')
-rw-r--r--usr.bin/lam/lam.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/usr.bin/lam/lam.c b/usr.bin/lam/lam.c
index a3a7f96b537..2c3e888efc4 100644
--- a/usr.bin/lam/lam.c
+++ b/usr.bin/lam/lam.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lam.c,v 1.6 2003/04/06 02:40:21 krw Exp $ */
+/* $OpenBSD: lam.c,v 1.7 2003/04/21 00:42:49 millert Exp $ */
/* $NetBSD: lam.c,v 1.2 1994/11/14 20:27:42 jtc Exp $ */
/*-
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)lam.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: lam.c,v 1.6 2003/04/06 02:40:21 krw Exp $";
+static char rcsid[] = "$OpenBSD: lam.c,v 1.7 2003/04/21 00:42:49 millert Exp $";
#endif /* not lint */
/*
@@ -178,14 +178,14 @@ char *
pad(ip)
struct openfile *ip;
{
- char *p = ip->sepstring;
+ size_t n;
char *lp = linep;
- while (*p)
- *lp++ = *p++;
+ n = strlcpy(lp, ip->sepstring, line + sizeof(line) - lp);
+ lp += (n < line + sizeof(line) - lp) ? n : strlen(lp);
if (ip->pad) {
- sprintf(lp, ip->format, "");
- lp += strlen(lp);
+ n = snprintf(lp, line + sizeof(line) - lp, ip->format, "");
+ lp += (n < line + sizeof(line) - lp) ? n : strlen(lp);
}
return (lp);
}
@@ -194,11 +194,12 @@ char *
gatherline(ip)
struct openfile *ip;
{
+ size_t n;
char s[BUFSIZ];
- int c;
char *p;
char *lp = linep;
char *end = s + BUFSIZ;
+ int c;
if (ip->eof)
return (pad(ip));
@@ -213,11 +214,10 @@ gatherline(ip)
morefiles--;
return (pad(ip));
}
- p = ip->sepstring;
- while (*p)
- *lp++ = *p++;
- sprintf(lp, ip->format, s);
- lp += strlen(lp);
+ n = strlcpy(lp, ip->sepstring, line + sizeof(line) - lp);
+ lp += (n < line + sizeof(line) - lp) ? n : strlen(lp);
+ n = snprintf(lp, line + sizeof line - lp, ip->format, s);
+ lp += (n < line + sizeof(line) - lp) ? n : strlen(lp);
return (lp);
}