patch-2.4.14 linux/fs/nfs/nfs2xdr.c

Next file: linux/fs/nfs/nfs3xdr.c
Previous file: linux/fs/jffs2/background.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.13/linux/fs/nfs/nfs2xdr.c linux/fs/nfs/nfs2xdr.c
@@ -471,6 +471,8 @@
 
 	for (nr = 0; *p++; nr++) {
 		entry = p - 1;
+		if (p + 2 > end)
+			goto short_pkt;
 		p++; /* fileid */
 		len = ntohl(*p++);
 		p += XDR_QUADLEN(len) + 1;	/* name plus cookie */
@@ -479,13 +481,13 @@
 						len);
 			return -errno_NFSERR_IO;
 		}
-		if (p + 2 > end) {
-			printk(KERN_NOTICE
-				"NFS: short packet in readdir reply!\n");
-			entry[0] = entry[1] = 0;
-			break;
-		}
+		if (p + 2 > end)
+			goto short_pkt;
 	}
+	return nr;
+ short_pkt:
+	printk(KERN_NOTICE "NFS: short packet in readdir reply!\n");
+	entry[0] = entry[1] = 0;
 	return nr;
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)