]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[nfs] Fix an invalid free() when loading a regular (non-symlink) file
authorMarin Hannache <git@mareo.fr>
Thu, 15 May 2014 17:05:48 +0000 (19:05 +0200)
committerMichael Brown <mcb30@ipxe.org>
Fri, 16 May 2014 10:01:39 +0000 (11:01 +0100)
An invalid free() was ironically introduced by fixing another invalid
free in commit 7aa69c4 ("[nfs] Fix an invalid free() when loading a
symlink").

Signed-off-by: Marin Hannache <git@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/net/oncrpc/nfs_open.c

index e9f5f9cfef55432dbf3f26e80d75d04c7e889d13..68f406f41bbb33e16f115118959366ac596f385b 100644 (file)
@@ -145,7 +145,7 @@ static void nfs_done ( struct nfs_request *nfs, int rc ) {
 
        DBGC ( nfs, "NFS_OPEN %p completed (%s)\n", nfs, strerror ( rc ) );
 
-       free ( nfs->filename );
+       free ( nfs->filename - nfs->filename_offset );
 
        intf_shutdown ( &nfs->xfer, rc );
        intf_shutdown ( &nfs->pm_intf, rc );
@@ -327,8 +327,9 @@ static int nfs_mount_deliver ( struct nfs_request *nfs,
                                goto err;
 
                        sep = strrchr ( nfs->mountpoint, '/' );
-                       nfs->filename[-1] = '/';
-                       nfs->filename     = sep + 1;
+                       nfs->filename[-1]    = '/';
+                       nfs->filename_offset = sep + 1 - nfs->filename;
+                       nfs->filename        = sep + 1;
                        *sep = '\0';
 
                        DBGC ( nfs, "NFS_OPEN %p ENOTDIR received retrying" \