DragonFlyBSD Kernel Audit
DF-0810 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/vfs/nfs/nfs_subs.c b/sys/vfs/nfs/nfs_subs.c
--- a/sys/vfs/nfs/nfs_subs.c
+++ b/sys/vfs/nfs/nfs_subs.c
@@ -1336,9 +1336,18 @@
 nfs_getcookie(struct nfsnode *np, off_t off, int add)
 {
 	struct nfsdmap *dp, *dp2;
+	uoff_t upos;
 	int pos;
 
-	pos = (uoff_t)off / NFS_DIRBLKSIZ;
+	upos = (uoff_t)off / NFS_DIRBLKSIZ;
+	if (upos > (uoff_t)INT_MAX) {
+#ifdef DIAGNOSTIC
+		if (add)
+			panic("nfs getcookie add at > INT_MAX blocks");
+#endif
+		return (NULL);
+	}
+	pos = (int)upos;
 	if (pos == 0 || off < 0) {
 #ifdef DIAGNOSTIC
 		if (add)