Procházet zdrojové kódy

[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>
tags/v1.20.1
Marin Hannache před 10 roky
rodič
revize
7aa69c4d0d
1 změnil soubory, kde provedl 11 přidání a 0 odebrání
  1. 11
    0
      src/net/oncrpc/nfs_open.c

+ 11
- 0
src/net/oncrpc/nfs_open.c Zobrazit soubor

@@ -145,6 +145,8 @@ static void nfs_done ( struct nfs_request *nfs, int rc ) {
145 145
 
146 146
 	DBGC ( nfs, "NFS_OPEN %p completed (%s)\n", nfs, strerror ( rc ) );
147 147
 
148
+	free ( nfs->filename );
149
+
148 150
 	intf_shutdown ( &nfs->xfer, rc );
149 151
 	intf_shutdown ( &nfs->pm_intf, rc );
150 152
 	intf_shutdown ( &nfs->mount_intf, rc );
@@ -334,6 +336,15 @@ static int nfs_mount_deliver ( struct nfs_request *nfs,
334 336
 			goto done;
335 337
 		}
336 338
 
339
+		/* We need to strdup() nfs->filename since the code handling
340
+		 * symlink resolution make the assumption that it can be
341
+		 * free()ed. */
342
+		if ( ( nfs->filename = strdup ( nfs->filename ) ) == NULL )
343
+		{
344
+			rc = -ENOMEM;
345
+			goto err;
346
+		}
347
+
337 348
 		nfs->current_fh = mnt_reply.fh;
338 349
 		nfs->nfs_state = NFS_LOOKUP;
339 350
 		nfs_step ( nfs );

Načítá se…
Zrušit
Uložit