diff options
author | 2017-08-28 18:52:25 +0000 | |
---|---|---|
committer | 2017-08-28 18:52:25 +0000 | |
commit | c522126c9da095eeb2147df402dda2da1a31d96c (patch) | |
tree | be4f1b24633c0e0d08bc3c5e2d82a6b5bf420410 /usr.bin/cvs/rcs.c | |
parent | sync (diff) | |
download | wireguard-openbsd-c522126c9da095eeb2147df402dda2da1a31d96c.tar.xz wireguard-openbsd-c522126c9da095eeb2147df402dda2da1a31d96c.zip |
Use xasprintf() instead of calloc() + strlcpy() + memcpy() to
generate the log line. Fixes a clang warning about using the wrong
size argument in strlcpy(). The existing code was safe but not
good strlcpy() practice. OK otto@
Diffstat (limited to 'usr.bin/cvs/rcs.c')
-rw-r--r-- | usr.bin/cvs/rcs.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c index 3efe66a3752..bbbc7708bf1 100644 --- a/usr.bin/cvs/rcs.c +++ b/usr.bin/cvs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.317 2017/05/31 16:31:55 joris Exp $ */ +/* $OpenBSD: rcs.c,v 1.318 2017/08/28 18:52:25 millert Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -2463,12 +2463,8 @@ rcs_kwexp_line(char *rcsfile, struct rcs_delta *rdp, struct rcs_lines *lines, * trailing whitespaces of our prefix. */ lp = xcalloc(1, sizeof(*lp)); - lp->l_line = xcalloc(strlen(sprefix) + - line->l_line + line->l_len - end + 1, 1); - strlcpy(lp->l_line, sprefix, - strlen(sprefix) + 1); - memcpy(lp->l_line + strlen(sprefix), - end, line->l_line + line->l_len - end); + xasprintf((char **)&lp->l_line, "%s%s", + sprefix, end); lp->l_len = strlen(lp->l_line); TAILQ_INSERT_AFTER(&(lines->l_lines), cur, lp, l_list); |