NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/57279: 32 bit time_t leftover in NFS code



>Number:         57279
>Category:       kern
>Synopsis:       32 bit time_t leftover in NFS code
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 21 14:20:00 +0000 2023
>Originator:     Izumi Tsutsui
>Release:        NetBSD 9.3 and -current
>Organization:
>Environment:
System: NetBSD mirage 9.3 NetBSD 9.3 (GENERIC) #0: Thu Aug 4 15:30:37 UTC 2022 mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/i386/compile/GENERIC i386
Architecture: all
Machine: all
>Description:
There are calculations that use int or long for time_t time_second
or tv_sec in src/sys/nfs.

>How-To-Repeat:
Code inspection.
(maybe we need some lint tools for time_t calculations?)

>Fix:
Index: sys/nfs/nfs_clntsubs.c
===================================================================
RCS file: /cvsroot/src/sys/nfs/nfs_clntsubs.c,v
retrieving revision 1.6
diff -u -p -d -r1.6 nfs_clntsubs.c
--- sys/nfs/nfs_clntsubs.c	28 Feb 2022 08:45:36 -0000	1.6
+++ sys/nfs/nfs_clntsubs.c	21 Mar 2023 14:09:19 -0000
@@ -390,7 +390,7 @@ nfs_check_wccdata(struct nfsnode *np, co
 	if (docheck) {
 		struct vnode *vp = NFSTOV(np);
 		struct nfsmount *nmp;
-		long now = time_second;
+		time_t now = time_second;
 		const struct timespec *omtime = &np->n_vattr->va_mtime;
 		const struct timespec *octime = &np->n_vattr->va_ctime;
 		const char *reason = NULL; /* XXX: gcc */
Index: sys/nfs/nfs_iod.c
===================================================================
RCS file: /cvsroot/src/sys/nfs/nfs_iod.c,v
retrieving revision 1.8
diff -u -p -d -r1.8 nfs_iod.c
--- sys/nfs/nfs_iod.c	3 Sep 2018 16:29:36 -0000	1.8
+++ sys/nfs/nfs_iod.c	21 Mar 2023 14:09:19 -0000
@@ -409,7 +409,8 @@ nfs_savenickauth(struct nfsmount *nmp, k
 	struct timeval ktvin, ktvout;
 	u_int32_t nick;
 	char *dpos = *dposp, *cp2;
-	int deltasec, error = 0;
+	time_t deltasec;
+	int error = 0;
 
 	memset(&ktvout, 0, sizeof ktvout);	 /* XXX gcc */
 
Index: sys/nfs/nfs_vfsops.c
===================================================================
RCS file: /cvsroot/src/sys/nfs/nfs_vfsops.c,v
retrieving revision 1.244
diff -u -p -d -r1.244 nfs_vfsops.c
--- sys/nfs/nfs_vfsops.c	17 Mar 2023 00:46:35 -0000	1.244
+++ sys/nfs/nfs_vfsops.c	21 Mar 2023 14:09:19 -0000
@@ -323,7 +323,7 @@ nfs_mountroot(void)
 	struct mount *mp;
 	struct vnode *vp;
 	struct lwp *l;
-	long n;
+	time_t n;
 	int error;
 
 	l = curlwp; /* XXX */
@@ -378,7 +378,7 @@ nfs_mountroot(void)
 		panic("nfs_mountroot: getattr for root");
 	n = attr.va_atime.tv_sec;
 #ifdef	DEBUG
-	printf("root time: 0x%lx\n", n);
+	printf("root time: 0x%" PRIx64 "\n", n);
 #endif
 	setrootfstime(n);
 



Home | Main Index | Thread Index | Old Index