diff options
author | 2006-03-30 06:07:35 +0000 | |
---|---|---|
committer | 2006-03-30 06:07:35 +0000 | |
commit | 0f9a9ee20bd09caa85fea6099d89dc2f88186502 (patch) | |
tree | 4aba419a1f870e1b7612b89390e70ecf98dbc8ca | |
parent | Document 'F' as an answer to fsck, okay deraadt@ jolan@ (diff) | |
download | wireguard-openbsd-0f9a9ee20bd09caa85fea6099d89dc2f88186502.tar.xz wireguard-openbsd-0f9a9ee20bd09caa85fea6099d89dc2f88186502.zip |
- Comment fixes.
- int rcsnum_cpy() -> void rcsnum_cpy().
- Check for overflow in rcsnum_cpy().
OK niallo@
-rw-r--r-- | usr.bin/cvs/rcs.h | 4 | ||||
-rw-r--r-- | usr.bin/cvs/rcsnum.c | 18 |
2 files changed, 9 insertions, 13 deletions
diff --git a/usr.bin/cvs/rcs.h b/usr.bin/cvs/rcs.h index cba66110caf..6a926aeff66 100644 --- a/usr.bin/cvs/rcs.h +++ b/usr.bin/cvs/rcs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.h,v 1.54 2006/03/27 21:56:32 niallo Exp $ */ +/* $OpenBSD: rcs.h,v 1.55 2006/03/30 06:07:35 ray Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -266,7 +266,7 @@ RCSNUM *rcsnum_dec(RCSNUM *); void rcsnum_free(RCSNUM *); int rcsnum_aton(const char *, char **, RCSNUM *); char *rcsnum_tostr(const RCSNUM *, char *, size_t); -int rcsnum_cpy(const RCSNUM *, RCSNUM *, u_int); +void rcsnum_cpy(const RCSNUM *, RCSNUM *, u_int); int rcsnum_cmp(const RCSNUM *, const RCSNUM *, u_int); /* rcstime.c */ diff --git a/usr.bin/cvs/rcsnum.c b/usr.bin/cvs/rcsnum.c index 5431357e358..8a2273193dd 100644 --- a/usr.bin/cvs/rcsnum.c +++ b/usr.bin/cvs/rcsnum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsnum.c,v 1.29 2006/03/28 02:13:44 ray Exp $ */ +/* $OpenBSD: rcsnum.c,v 1.30 2006/03/30 06:07:35 ray Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -38,8 +38,7 @@ static char *rcsnum_itoa(u_int16_t, char *, size_t); /* * rcsnum_alloc() * - * Allocate an RCS number structure and return a pointer to it on success, - * or NULL on failure. + * Allocate an RCS number structure and return a pointer to it. */ RCSNUM * rcsnum_alloc(void) @@ -141,26 +140,23 @@ rcsnum_itoa(u_int16_t num, char *buf, size_t len) * rcsnum_cpy() * * Copy the number stored in <nsrc> in the destination <ndst> up to <depth> - * numbers deep. - * Returns 0 on success, or -1 on failure. + * numbers deep. If <depth> is 0, there is no depth limit. */ -int +void rcsnum_cpy(const RCSNUM *nsrc, RCSNUM *ndst, u_int depth) { u_int len; - size_t sz; void *tmp; len = nsrc->rn_len; if ((depth != 0) && (len > depth)) len = depth; - sz = len * sizeof(u_int16_t); - tmp = xrealloc(ndst->rn_id, 1, sz); + tmp = xrealloc(ndst->rn_id, len, sizeof(len)); ndst->rn_id = (u_int16_t *)tmp; ndst->rn_len = len; - memcpy(ndst->rn_id, nsrc->rn_id, sz); - return (0); + /* Overflow checked in xrealloc(). */ + memcpy(ndst->rn_id, nsrc->rn_id, len * sizeof(len)); } /* |