lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20071009171949.GA11579@Ahmed>
Date:	Tue, 9 Oct 2007 19:19:49 +0200
From:	"Ahmed S. Darwish" <darwish.07@...il.com>
To:	Randy Dunlap <randy.dunlap@...cle.com>
Cc:	Rob Landley <rob@...dley.net>, akpm@...ux-foundation.org,
	linux-kernel@...r.kernel.org, rdunlap@...otime.net
Subject: Re: [PATCH] Stop docproc segfaulting when SRCTREE isn't set.

On Tue, Oct 09, 2007 at 08:55:00AM -0700, Randy Dunlap wrote:
> On Tue, 9 Oct 2007 15:03:15 +0200 Ahmed S. Darwish wrote:
> 
> > Hi Rob,
> > 
> > On Tue, Oct 09, 2007 at 01:25:18AM -0500, Rob Landley wrote:
> > [...]
> > >  	FILE * infile;
> > > +
> > > +	srctree = getenv("SRCTREE");
> > > +	if (!srctree) srctree = getcwd(NULL,0);
> > >  	if (argc != 3) {
> > >  		usage();
> > >  		exit(1);
> > 
> > $ man getcwd
> > 
> >  char *getcwd(char *buf, size_t size);
> >       
> >  As an extension to the POSIX.1 standard, Linux (libc4, libc5, glibc) getcwd() 
> >  allocates the buffer dynamically using malloc() if buf is NULL on call.
> > 
> > Shouldn't "srctree" be free()ed in case getenv("SRCTREE") failed ?
> 
> What is there to free() at that point?  If getenv() fails (i.e.,
> the env. variable is not found), it returns NULL.
> or do I need another cup of coffee?
>

I meant if getenv() failed, "srctree = getcwd(NULL, 0)" will let 
"srctree" point to a _ malloc()ed _ buffer representing PWD. 
As said in the manpage, this buffer needs to be free()ed after usage.
Right or I'm the one who needs that cup of coffee :) ?

Regards,

-- 
Ahmed S. Darwish
HomePage: http://darwish.07.googlepages.com
Blog: http://darwish-07.blogspot.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ