summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2006-08-17 23:53:53 +0000
committerRay Lai <ray@cvs.openbsd.org>2006-08-17 23:53:53 +0000
commit50b85b2e44375b7b4401e6b94c3ef3f63f50e830 (patch)
treeca743b84e8fffc5487ff830747949653b7859349 /libexec
parentcfd819f3621e57ae50f24c29ff01b4dca7c7d12d (diff)
Instead of doing all this pointer and buffer arithmetic, generate string
using asprintf and strlcat it. Declare usage __dead instead of void in the prototype but static void in the definition. OK millert@
Diffstat (limited to 'libexec')
-rw-r--r--libexec/getNAME/getNAME.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/libexec/getNAME/getNAME.c b/libexec/getNAME/getNAME.c
index fb923e76c39..b51c1735f86 100644
--- a/libexec/getNAME/getNAME.c
+++ b/libexec/getNAME/getNAME.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getNAME.c,v 1.14 2006/06/21 19:57:42 jasper Exp $ */
+/* $OpenBSD: getNAME.c,v 1.15 2006/08/17 23:53:52 ray Exp $ */
/* $NetBSD: getNAME.c,v 1.7.2.1 1997/11/10 19:54:46 thorpej Exp $ */
/*-
@@ -40,7 +40,7 @@ static const char copyright[] =
#if 0
static char sccsid[] = "@(#)getNAME.c 8.1 (Berkeley) 6/30/93";
#else
-static const char rcsid[] = "$OpenBSD: getNAME.c,v 1.14 2006/06/21 19:57:42 jasper Exp $";
+static const char rcsid[] = "$OpenBSD: getNAME.c,v 1.15 2006/08/17 23:53:52 ray Exp $";
#endif
#endif /* not lint */
@@ -65,7 +65,7 @@ void dorefname(char *);
void getfrom(char *);
void split(char *, char *);
void trimln(char *);
-void usage(void);
+__dead void usage(void);
int main(int, char *[]);
int
@@ -240,9 +240,12 @@ newman:
*/
if (headbuf[1] == 'N' && headbuf[2] == 'd') {
if ((t = strchr(name, '.')) != NULL) {
- size_t len = strlen(linbuf);
- snprintf(linbuf+len, sizeof(linbuf)-len,
- "(%s)", t+1);
+ char *str;
+
+ if (asprintf(&str, "(%s)", t+1) == -1)
+ return;
+ strlcat(linbuf, str, sizeof(linbuf));
+ free(str);
}
strlcat(linbuf, "- ", sizeof(linbuf));
}
@@ -344,7 +347,7 @@ again:
putchar(*dp++);
}
-static void
+void
usage(void)
{
extern char *__progname;