bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mkdir vs. GPL


From: Eric Blake
Subject: Re: mkdir vs. GPL
Date: Thu, 29 Oct 2009 19:42:51 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Jim Meyering <jim <at> meyering.net> writes:

> >
> > Still to go - LGPL argp still depends on the GPL dirname module, because it
> > uses base_name (which xmallocs).  I can switch it to use last_component
> > instead, but will have to audit all clients that used __argp_dir_name to 
ensure
> > they are still correct.
> 
> Sounds good.

Audit complete.  argp leaks memory without this patch, and no risk of a bug 
with it, since all callers in argp assumes that __argp_dir_name does NOT malloc 
memory.


From: Eric Blake <address@hidden>
Date: Thu, 29 Oct 2009 13:38:52 -0600
Subject: [PATCH] argp: avoid memory leak

* modules/argp (Depends-on): Use dirname-lgpl, not dirname.
* lib/argp-namefrob.h (__argp_base_name): Use last_component, not
base_name, since the latter malloc()s and can call exit().

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog           |    5 +++++
 lib/argp-namefrob.h |    4 ++--
 modules/argp        |    2 +-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4396617..172fd91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2009-10-29  Eric Blake  <address@hidden>

+       argp: avoid memory leak
+       * modules/argp (Depends-on): Use dirname-lgpl, not dirname.
+       * lib/argp-namefrob.h (__argp_base_name): Use last_component, not
+       base_name, since the latter malloc()s and can call exit().
+
        filenamecat-lgpl: adjust clients
        * modules/linkat (Depends-on): Use filenamecat-lgpl, not
        filenamecat.
diff --git a/lib/argp-namefrob.h b/lib/argp-namefrob.h
index fcb082a..7b7b173 100644
--- a/lib/argp-namefrob.h
+++ b/lib/argp-namefrob.h
@@ -1,5 +1,5 @@
 /* Name frobnication for compiling argp outside of glibc
-   Copyright (C) 1997, 2003, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1997, 2003, 2007, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Miles Bader <address@hidden>.

@@ -147,7 +147,7 @@
 extern char *__argp_base_name(const char *arg);
 #else
 # include "dirname.h"
-# define __argp_base_name base_name
+# define __argp_base_name last_component
 #endif

 #if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
diff --git a/modules/argp b/modules/argp
index e772b3e..bb10844 100644
--- a/modules/argp
+++ b/modules/argp
@@ -24,7 +24,7 @@ m4/argp.m4

 Depends-on:
 alloca
-dirname
+dirname-lgpl
 getopt-gnu
 strchrnul
 sysexits
-- 
1.6.4.2







reply via email to

[Prev in Thread] Current Thread [Next in Thread]