PATCH 2.4.21 nfsroot.c buffercheck

From: Walter Harms (Walter.Harms@Informatik.Uni-Oldenburg.DE)
Date: Sat Jul 05 2003 - 12:24:01 EST


Hi Liste,
this patches fixes a wrong bordercheck and simplifies it.
Strings with NFS_MAXPATHLEN would pass in the old code.

walter

--- fs/nfs/nfsroot.c.org 2003-07-03 23:23:18.000000000 +0200
+++ fs/nfs/nfsroot.c 2003-07-03 23:36:51.000000000 +0200
@@ -207,7 +207,8 @@
 {
        char buf[NFS_MAXPATHLEN];
        char *cp;
-
+ int ret;
+
        /* Set some default values */
        memset(&nfs_data, 0, sizeof(nfs_data));
        nfs_port = -1;
@@ -230,14 +231,15 @@
        /* Override them by options set on kernel command-line */
        root_nfs_parse(name, buf);
 
- cp = system_utsname.nodename;
- if (strlen(buf) + strlen(cp) > NFS_MAXPATHLEN) {
- printk(KERN_ERR "Root-NFS: Pathname for remote directory too long.\n");
- return -1;
- }
- sprintf(nfs_path, buf, cp);
+ ret=snprintf(nfs_path,NFS_MAXPATHLEN, buf, system_utsname.nodename);
 
- return 1;
+ if (ret < NFS_MAXPATHLEN)
+ return 1;
+ else {
+ printk(KERN_ERR "Root-NFS: Pathname for remote directory too long.\n");
+ return -1;
+ }
+
 }
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Jul 07 2003 - 22:00:25 EST