Sun Mar 8 17:38:12 2020 UTC ()
Perform bit operations on unsigned integer

ext2fs_vnops.c:1002:2, signed integer overflow: 510008 * 4294 cannot be represented in type 'int

Maximum usec * 4294 is in the range of unsigned int.

>>> 1000000*4294
4294000000
>>> 2**32
4294967296

Patch submitted by Nisarg S. Joshi.


(kamil)
diff -r1.130 -r1.131 src/sys/ufs/ext2fs/ext2fs_vnops.c

cvs diff -r1.130 -r1.131 src/sys/ufs/ext2fs/ext2fs_vnops.c (expand / switch to unified diff)

--- src/sys/ufs/ext2fs/ext2fs_vnops.c 2019/09/18 17:59:15 1.130
+++ src/sys/ufs/ext2fs/ext2fs_vnops.c 2020/03/08 17:38:12 1.131
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ext2fs_vnops.c,v 1.130 2019/09/18 17:59:15 christos Exp $ */ 1/* $NetBSD: ext2fs_vnops.c,v 1.131 2020/03/08 17:38:12 kamil Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1982, 1986, 1989, 1993 4 * Copyright (c) 1982, 1986, 1989, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc. 6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed 7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph 8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc. 10 * the permission of UNIX System Laboratories, Inc.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -55,27 +55,27 @@ @@ -55,27 +55,27 @@
55 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 55 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
56 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 56 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
57 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 57 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 58 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 59 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 60 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
61 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 61 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62 * 62 *
63 * @(#)ufs_vnops.c 8.14 (Berkeley) 10/26/94 63 * @(#)ufs_vnops.c 8.14 (Berkeley) 10/26/94
64 * Modified for ext2fs by Manuel Bouyer. 64 * Modified for ext2fs by Manuel Bouyer.
65 */ 65 */
66 66
67#include <sys/cdefs.h> 67#include <sys/cdefs.h>
68__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.130 2019/09/18 17:59:15 christos Exp $"); 68__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.131 2020/03/08 17:38:12 kamil Exp $");
69 69
70#include <sys/param.h> 70#include <sys/param.h>
71#include <sys/systm.h> 71#include <sys/systm.h>
72#include <sys/resourcevar.h> 72#include <sys/resourcevar.h>
73#include <sys/kernel.h> 73#include <sys/kernel.h>
74#include <sys/file.h> 74#include <sys/file.h>
75#include <sys/stat.h> 75#include <sys/stat.h>
76#include <sys/buf.h> 76#include <sys/buf.h>
77#include <sys/proc.h> 77#include <sys/proc.h>
78#include <sys/mount.h> 78#include <sys/mount.h>
79#include <sys/namei.h> 79#include <sys/namei.h>
80#include <sys/vnode.h> 80#include <sys/vnode.h>
81#include <sys/lockf.h> 81#include <sys/lockf.h>
@@ -989,27 +989,27 @@ ext2fs_vinit(struct mount *mntp, int (** @@ -989,27 +989,27 @@ ext2fs_vinit(struct mount *mntp, int (**
989 case VSOCK: 989 case VSOCK:
990 case VLNK: 990 case VLNK:
991 case VDIR: 991 case VDIR:
992 case VREG: 992 case VREG:
993 break; 993 break;
994 } 994 }
995 if (ip->i_number == UFS_ROOTINO) 995 if (ip->i_number == UFS_ROOTINO)
996 vp->v_vflag |= VV_ROOT; 996 vp->v_vflag |= VV_ROOT;
997 /* 997 /*
998 * Initialize modrev times 998 * Initialize modrev times
999 */ 999 */
1000 getmicrouptime(&tv); 1000 getmicrouptime(&tv);
1001 SETHIGH(ip->i_modrev, tv.tv_sec); 1001 SETHIGH(ip->i_modrev, tv.tv_sec);
1002 SETLOW(ip->i_modrev, tv.tv_usec * 4294); 1002 SETLOW(ip->i_modrev, tv.tv_usec * 4294U);
1003 *vpp = vp; 1003 *vpp = vp;
1004 return 0; 1004 return 0;
1005} 1005}
1006 1006
1007/* 1007/*
1008 * Allocate a new inode. 1008 * Allocate a new inode.
1009 */ 1009 */
1010static int 1010static int
1011ext2fs_makeinode(struct vattr *vap, struct vnode *dvp, struct vnode **vpp, 1011ext2fs_makeinode(struct vattr *vap, struct vnode *dvp, struct vnode **vpp,
1012 struct componentname *cnp, int do_direnter) 1012 struct componentname *cnp, int do_direnter)
1013{ 1013{
1014 struct inode *ip, *pdir; 1014 struct inode *ip, *pdir;
1015 struct vnode *tvp; 1015 struct vnode *tvp;