summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authormaxim <maxim@FreeBSD.org>2006-08-09 19:12:10 +0000
committermaxim <maxim@FreeBSD.org>2006-08-09 19:12:10 +0000
commitcf6dea33f23e8370e4c939b145a33708a21e4ed3 (patch)
tree389ae35c14346db8e5171b4b7236ba840b5fae81 /usr.bin
parentbf73c5645f868bdfc4f2384e568d7e2d670be30b (diff)
downloadFreeBSD-src-cf6dea33f23e8370e4c939b145a33708a21e4ed3.zip
FreeBSD-src-cf6dea33f23e8370e4c939b145a33708a21e4ed3.tar.gz
o Simple strcpy/strcat replacement.
PR: bin/101575 Founded by: Dan Lukes Obtained from: OpenBSD, rev. 1.11 by deraadt MFC after: 2 weeks
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/hexdump/parse.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/hexdump/parse.c b/usr.bin/hexdump/parse.c
index 1231a15..ef19278 100644
--- a/usr.bin/hexdump/parse.c
+++ b/usr.bin/hexdump/parse.c
@@ -213,6 +213,7 @@ rewrite(FS *fs)
unsigned char *p1, *p2, *fmtp;
char savech, cs[3];
int nconv, prec;
+ size_t len;
nextpr = NULL;
prec = 0;
@@ -394,10 +395,10 @@ isint2: switch(fu->bcnt) {
*/
savech = *p2;
p1[0] = '\0';
- if ((pr->fmt = calloc(1, strlen(fmtp) + 2)) == NULL)
+ len = strlen(fmtp) + strlen(cs) + 1;
+ if ((pr->fmt = calloc(1, len)) == NULL)
err(1, NULL);
- (void)strcpy(pr->fmt, fmtp);
- (void)strcat(pr->fmt, cs);
+ snprintf(pr->fmt, len, "%s%s", fmtp, cs);
*p2 = savech;
pr->cchar = pr->fmt + (p1 - fmtp);
fmtp = p2;
OpenPOWER on IntegriCloud