Wed May 20 18:21:17 2015 UTC ()
memcpy di_extb/db/ib separately.  Noted by Coverity, CID 974636.


(riastradh)
diff -r1.38 -r1.39 src/sys/ufs/ffs/ffs_bswap.c

cvs diff -r1.38 -r1.39 src/sys/ufs/ffs/ffs_bswap.c (expand / switch to unified diff)

--- src/sys/ufs/ffs/ffs_bswap.c 2015/05/20 18:19:09 1.38
+++ src/sys/ufs/ffs/ffs_bswap.c 2015/05/20 18:21:17 1.39
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ffs_bswap.c,v 1.38 2015/05/20 18:19:09 riastradh Exp $ */ 1/* $NetBSD: ffs_bswap.c,v 1.39 2015/05/20 18:21:17 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1998 Manuel Bouyer. 4 * Copyright (c) 1998 Manuel Bouyer.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 * 25 *
26 */ 26 */
27 27
28#if HAVE_NBTOOL_CONFIG_H 28#if HAVE_NBTOOL_CONFIG_H
29#include "nbtool_config.h" 29#include "nbtool_config.h"
30#endif 30#endif
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: ffs_bswap.c,v 1.38 2015/05/20 18:19:09 riastradh Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: ffs_bswap.c,v 1.39 2015/05/20 18:21:17 riastradh Exp $");
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#if defined(_KERNEL) 36#if defined(_KERNEL)
37#include <sys/systm.h> 37#include <sys/systm.h>
38#endif 38#endif
39 39
40#include <ufs/ufs/dinode.h> 40#include <ufs/ufs/dinode.h>
41#include <ufs/ufs/quota.h> 41#include <ufs/ufs/quota.h>
42#include <ufs/ufs/ufs_bswap.h> 42#include <ufs/ufs/ufs_bswap.h>
43#include <ufs/ffs/fs.h> 43#include <ufs/ffs/fs.h>
44#include <ufs/ffs/ffs_extern.h> 44#include <ufs/ffs/ffs_extern.h>
45 45
46#if !defined(_KERNEL) 46#if !defined(_KERNEL)
@@ -149,27 +149,29 @@ ffs_dinode2_swap(struct ufs2_dinode *o,  @@ -149,27 +149,29 @@ ffs_dinode2_swap(struct ufs2_dinode *o,
149 n->di_blocks = bswap64(o->di_blocks); 149 n->di_blocks = bswap64(o->di_blocks);
150 n->di_atime = bswap64(o->di_atime); 150 n->di_atime = bswap64(o->di_atime);
151 n->di_atimensec = bswap32(o->di_atimensec); 151 n->di_atimensec = bswap32(o->di_atimensec);
152 n->di_mtime = bswap64(o->di_mtime); 152 n->di_mtime = bswap64(o->di_mtime);
153 n->di_mtimensec = bswap32(o->di_mtimensec); 153 n->di_mtimensec = bswap32(o->di_mtimensec);
154 n->di_ctime = bswap64(o->di_ctime); 154 n->di_ctime = bswap64(o->di_ctime);
155 n->di_ctimensec = bswap32(o->di_ctimensec); 155 n->di_ctimensec = bswap32(o->di_ctimensec);
156 n->di_birthtime = bswap64(o->di_birthtime); 156 n->di_birthtime = bswap64(o->di_birthtime);
157 n->di_birthnsec = bswap32(o->di_birthnsec); 157 n->di_birthnsec = bswap32(o->di_birthnsec);
158 n->di_gen = bswap32(o->di_gen); 158 n->di_gen = bswap32(o->di_gen);
159 n->di_kernflags = bswap32(o->di_kernflags); 159 n->di_kernflags = bswap32(o->di_kernflags);
160 n->di_flags = bswap32(o->di_flags); 160 n->di_flags = bswap32(o->di_flags);
161 n->di_extsize = bswap32(o->di_extsize); 161 n->di_extsize = bswap32(o->di_extsize);
162 memcpy(n->di_extb, o->di_extb, (UFS_NXADDR + UFS_NDADDR + UFS_NIADDR) * 8); 162 memcpy(n->di_extb, o->di_extb, sizeof(n->di_extb));
 163 memcpy(n->di_db, o->di_db, sizeof(n->di_db));
 164 memcpy(n->di_ib, o->di_ib, sizeof(n->di_ib));
163} 165}
164 166
165void 167void
166ffs_csum_swap(struct csum *o, struct csum *n, int size) 168ffs_csum_swap(struct csum *o, struct csum *n, int size)
167{ 169{
168 size_t i; 170 size_t i;
169 u_int32_t *oint, *nint; 171 u_int32_t *oint, *nint;
170 172
171 oint = (u_int32_t*)o; 173 oint = (u_int32_t*)o;
172 nint = (u_int32_t*)n; 174 nint = (u_int32_t*)n;
173 175
174 for (i = 0; i < size / sizeof(u_int32_t); i++) 176 for (i = 0; i < size / sizeof(u_int32_t); i++)
175 nint[i] = bswap32(oint[i]); 177 nint[i] = bswap32(oint[i]);