diff options
author | maxim <maxim@FreeBSD.org> | 2006-08-09 19:12:10 +0000 |
---|---|---|
committer | maxim <maxim@FreeBSD.org> | 2006-08-09 19:12:10 +0000 |
commit | cf6dea33f23e8370e4c939b145a33708a21e4ed3 (patch) | |
tree | 389ae35c14346db8e5171b4b7236ba840b5fae81 | |
parent | bf73c5645f868bdfc4f2384e568d7e2d670be30b (diff) | |
download | FreeBSD-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
-rw-r--r-- | usr.bin/hexdump/parse.c | 7 |
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; |