Paul Smith wrote:
> > Would you approve this license change for this contribution?
> 
> Yes, that's fine.

Thank you. Done through the two attached patches.


2020-12-10  Bruno Haible  <br...@clisp.org>

        findprog-in: Relicense under LGPLv2+.
        Paul Smith's approval is in
        <https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00072.html>.
        * modules/findprog-in (License): Change to LGPLv2+.

2020-12-10  Bruno Haible  <br...@clisp.org>

        findprog-in: Don't exit upon out-of-memory.
        * lib/findprog.h (find_in_given_path): Document ENOMEM as possible error
        code.
        * lib/findprog-in.c: Don't include xalloc.h.
        (find_in_given_path): Call concatenated_filename, not
        xconcatenated_filename. Call strdup, not xstrdup. Upon out-of-memory,
        return NULL with errno set.
        * modules/findprog-in (Depends-on): Remove xconcat-filename, xalloc. Add
        concat-filename, strdup-posix, malloc-posix.

>From 5fde00bdb689884f6de0ab2829f0df907380a010 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Thu, 10 Dec 2020 21:32:54 +0100
Subject: [PATCH 1/4] findprog-in: Don't exit upon out-of-memory.

* lib/findprog.h (find_in_given_path): Document ENOMEM as possible error
code.
* lib/findprog-in.c: Don't include xalloc.h.
(find_in_given_path): Call concatenated_filename, not
xconcatenated_filename. Call strdup, not xstrdup. Upon out-of-memory,
return NULL with errno set.
* modules/findprog-in (Depends-on): Remove xconcat-filename, xalloc. Add
concat-filename, strdup-posix, malloc-posix.
---
 ChangeLog           | 12 ++++++++++++
 lib/findprog-in.c   | 31 +++++++++++++++++++++++++------
 lib/findprog.h      |  1 +
 modules/findprog-in |  5 +++--
 4 files changed, 41 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8c05ee6..d4c17d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2020-12-10  Bruno Haible  <br...@clisp.org>
+
+	findprog-in: Don't exit upon out-of-memory.
+	* lib/findprog.h (find_in_given_path): Document ENOMEM as possible error
+	code.
+	* lib/findprog-in.c: Don't include xalloc.h.
+	(find_in_given_path): Call concatenated_filename, not
+	xconcatenated_filename. Call strdup, not xstrdup. Upon out-of-memory,
+	return NULL with errno set.
+	* modules/findprog-in (Depends-on): Remove xconcat-filename, xalloc. Add
+	concat-filename, strdup-posix, malloc-posix.
+
 2020-12-09  Bruno Haible  <br...@clisp.org>
 
 	fmaf: Work around a bug on FreeBSD 12.2/arm.
diff --git a/lib/findprog-in.c b/lib/findprog-in.c
index 0f76e36..863f67e 100644
--- a/lib/findprog-in.c
+++ b/lib/findprog-in.c
@@ -30,7 +30,6 @@
 
 #include "filename.h"
 #include "concat-filename.h"
-#include "xalloc.h"
 
 #if (defined _WIN32 && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__
   /* Native Windows, OS/2, DOS */
@@ -129,7 +128,10 @@ find_in_given_path (const char *progname, const char *path,
                   {
                     /* Concatenate progname and suffix.  */
                     char *progpathname =
-                      xconcatenated_filename ("", progname, suffix);
+                      concatenated_filename ("", progname, suffix);
+
+                    if (progpathname == NULL)
+                      return NULL; /* errno is set here */
 
                     /* On systems which have the eaccess() system call, let's
                        use it.  On other systems, let's hope that this program
@@ -178,9 +180,12 @@ find_in_given_path (const char *progname, const char *path,
     path = "";
 
   {
-    int failure_errno;
     /* Make a copy, to prepare for destructive modifications.  */
-    char *path_copy = xstrdup (path);
+    char *path_copy = strdup (path);
+    if (path_copy == NULL)
+      return NULL; /* errno is set here */
+
+    int failure_errno;
     char *path_rest;
     char *cp;
 
@@ -215,7 +220,14 @@ find_in_given_path (const char *progname, const char *path,
               {
                 /* Concatenate dir, progname, and suffix.  */
                 char *progpathname =
-                  xconcatenated_filename (dir, progname, suffix);
+                  concatenated_filename (dir, progname, suffix);
+
+                if (progpathname == NULL)
+                  {
+                    /* errno is set here.  */
+                    failure_errno = errno;
+                    goto failed;
+                  }
 
                 /* On systems which have the eaccess() system call, let's
                    use it.  On other systems, let's hope that this program
@@ -241,7 +253,13 @@ find_in_given_path (const char *progname, const char *path,
                                    This avoids a second PATH search when the
                                    caller uses execl/execv/execlp/execvp.  */
                                 progpathname =
-                                  XNMALLOC (2 + strlen (progname) + 1, char);
+                                  (char *) malloc (2 + strlen (progname) + 1);
+                                if (progpathname == NULL)
+                                  {
+                                    /* errno is set here.  */
+                                    failure_errno = errno;
+                                    goto failed;
+                                  }
                                 progpathname[0] = '.';
                                 progpathname[1] = NATIVE_SLASH;
                                 memcpy (progpathname + 2, progname,
@@ -267,6 +285,7 @@ find_in_given_path (const char *progname, const char *path,
           break;
       }
 
+   failed:
     /* Not found in PATH.  */
     free (path_copy);
 
diff --git a/lib/findprog.h b/lib/findprog.h
index aef6289..c020290 100644
--- a/lib/findprog.h
+++ b/lib/findprog.h
@@ -53,6 +53,7 @@ extern const char *find_in_path (const char *progname);
        - EACCES: means that the program's file cannot be accessed (due to some
          issue with one of the ancestor directories) or lacks the execute
          permissions.
+       - ENOMEM: means out of memory.
    If OPTIMIZE_FOR_EXEC is true, the function saves some work, under the
    assumption that the resulting pathname will not be accessed directly,
    only through execl/execv or execlp/execvp.
diff --git a/modules/findprog-in b/modules/findprog-in
index 84787a6..694c503 100644
--- a/modules/findprog-in
+++ b/modules/findprog-in
@@ -11,10 +11,11 @@ Depends-on:
 stdbool
 sys_stat
 filename
-xalloc
-xconcat-filename
+concat-filename
 access
 stat
+strdup-posix
+malloc-posix
 unistd
 
 configure.ac:
-- 
2.7.4

>From 3cd245c6a6e8823af3a5b23099c84cf99e6a12dc Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Thu, 10 Dec 2020 21:47:39 +0100
Subject: [PATCH 2/4] findprog-in: Relicense under LGPLv2+.

Paul Smith's approval is in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00072.html>.

* modules/findprog-in (License): Change to LGPLv2+.
---
 ChangeLog           | 7 +++++++
 modules/findprog-in | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index d4c17d0..89ea7f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2020-12-10  Bruno Haible  <br...@clisp.org>
 
+	findprog-in: Relicense under LGPLv2+.
+	Paul Smith's approval is in
+	<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00072.html>.
+	* modules/findprog-in (License): Change to LGPLv2+.
+
+2020-12-10  Bruno Haible  <br...@clisp.org>
+
 	findprog-in: Don't exit upon out-of-memory.
 	* lib/findprog.h (find_in_given_path): Document ENOMEM as possible error
 	code.
diff --git a/modules/findprog-in b/modules/findprog-in
index 694c503..5f04377 100644
--- a/modules/findprog-in
+++ b/modules/findprog-in
@@ -28,7 +28,7 @@ Include:
 "findprog.h"
 
 License:
-GPL
+LGPLv2+
 
 Maintainer:
 all
-- 
2.7.4

Reply via email to