Linux NFS development
 help / color / mirror / Atom feed
From: Olaf Kirch <okir@suse.de>
To: nfs@lists.sourceforge.net
Cc: nfbrown@suse.de
Subject: [PATCH] Do not leak memory in is_mountpoint()
Date: Wed, 29 Nov 2006 12:51:03 +0100	[thread overview]
Message-ID: <20061129115103.GB18149@suse.de> (raw)


Not sure if this was discussed before. Anyway, I
stumbled across this today.

Cheers,
Olaf
------------------------------------------------------------------
From: Olaf Kirch <okir@suse.de>
Subject: Do not leak memory in is_mountpoint()

Kind of obvious when you look at the code :-)

Signed-off-by: Olaf Kirch <okir@suse.de>

 support/misc/mountpoint.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

Index: nfs-utils-1.0.8/support/misc/mountpoint.c
===================================================================
--- nfs-utils-1.0.8.orig/support/misc/mountpoint.c
+++ nfs-utils-1.0.8/support/misc/mountpoint.c
@@ -20,17 +20,20 @@ is_mountpoint(char *path)
 	 */
 	char *dotdot;
 	struct stat stb, pstb;
+	int rv = 0;
 
 	dotdot = malloc(strlen(path)+4);
 	strcat(strcpy(dotdot, path), "/..");
 	if (lstat(path, &stb) != 0 ||
 	    lstat(dotdot, &pstb) != 0)
-		return 0;
+		goto done;
 
 	if (stb.st_dev != pstb.st_dev
 	    || stb.st_ino == pstb.st_ino)
-		return 1;
-	return 0;
+		rv = 1;
+
+done:	free(dotdot);
+	return rv;
 }
 
 int
-- 
Walks like a duck. Quacks like a duck. Must be a chicken.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

             reply	other threads:[~2006-11-29 11:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-29 11:51 Olaf Kirch [this message]
2006-11-29 12:13 ` [PATCH] Do not leak memory in is_mountpoint() Olaf Kirch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061129115103.GB18149@suse.de \
    --to=okir@suse.de \
    --cc=nfbrown@suse.de \
    --cc=nfs@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox