|
|
d7a338 |
From de11338de900f5c8840268264bceccbf76cca34f Mon Sep 17 00:00:00 2001
|
|
|
d7a338 |
From: Daiki Ueno <dueno@redhat.com>
|
|
|
d7a338 |
Date: Thu, 21 Oct 2021 12:19:30 +0200
|
|
|
d7a338 |
Subject: [PATCH 1/2] autoopts: makeshell: use ferror before fclose
|
|
|
d7a338 |
|
|
|
d7a338 |
Signed-off-by: Daiki Ueno <dueno@redhat.com>
|
|
|
d7a338 |
---
|
|
|
d7a338 |
src/libopts/makeshell.c | 3 +--
|
|
|
d7a338 |
1 file changed, 1 insertion(+), 2 deletions(-)
|
|
|
d7a338 |
|
|
|
d7a338 |
diff --git a/src/libopts/makeshell.c b/src/libopts/makeshell.c
|
|
|
d7a338 |
index b6cb441a..7eb17a1f 100644
|
|
|
d7a338 |
--- a/src/libopts/makeshell.c
|
|
|
d7a338 |
+++ b/src/libopts/makeshell.c
|
|
|
d7a338 |
@@ -164,9 +164,8 @@ optionParseShell(tOptions * opts)
|
|
|
d7a338 |
#ifdef HAVE_FCHMOD
|
|
|
d7a338 |
fchmod(STDOUT_FILENO, 0755);
|
|
|
d7a338 |
#endif
|
|
|
d7a338 |
- fclose(stdout);
|
|
|
d7a338 |
|
|
|
d7a338 |
- if (ferror(stdout))
|
|
|
d7a338 |
+ if (ferror(stdout) || fclose(stdout))
|
|
|
d7a338 |
fserr_exit(opts->pzProgName, zwriting, zstdout_name);
|
|
|
d7a338 |
|
|
|
d7a338 |
AGFREE(script_text);
|
|
|
d7a338 |
--
|
|
|
d7a338 |
2.31.1
|
|
|
d7a338 |
|
|
|
d7a338 |
|
|
|
d7a338 |
From 161097d36b608b615482e42e56a465c9fd740c26 Mon Sep 17 00:00:00 2001
|
|
|
d7a338 |
From: Daiki Ueno <dueno@redhat.com>
|
|
|
d7a338 |
Date: Thu, 21 Oct 2021 12:43:07 +0200
|
|
|
d7a338 |
Subject: [PATCH 2/2] autoopts: load: fix resource leak in error path
|
|
|
d7a338 |
|
|
|
d7a338 |
Signed-off-by: Daiki Ueno <dueno@redhat.com>
|
|
|
d7a338 |
---
|
|
|
d7a338 |
src/libopts/load.c | 10 ++++++++--
|
|
|
d7a338 |
1 file changed, 8 insertions(+), 2 deletions(-)
|
|
|
d7a338 |
|
|
|
d7a338 |
diff --git a/src/libopts/load.c b/src/libopts/load.c
|
|
|
d7a338 |
index 3f1ce2e6..ad1c4584 100644
|
|
|
d7a338 |
--- a/src/libopts/load.c
|
|
|
d7a338 |
+++ b/src/libopts/load.c
|
|
|
d7a338 |
@@ -219,8 +219,11 @@ add_prog_path(char * buf, int b_sz, char const * fname, char const * prg_path)
|
|
|
d7a338 |
* IF we cannot find a directory name separator,
|
|
|
d7a338 |
* THEN we do not have a path name to our executable file.
|
|
|
d7a338 |
*/
|
|
|
d7a338 |
- if (pz == NULL)
|
|
|
d7a338 |
+ if (pz == NULL) {
|
|
|
d7a338 |
+ if (path != prg_path)
|
|
|
d7a338 |
+ AGFREE(path);
|
|
|
d7a338 |
return false;
|
|
|
d7a338 |
+ }
|
|
|
d7a338 |
|
|
|
d7a338 |
fname += skip;
|
|
|
d7a338 |
fname_len = strlen(fname) + 1; // + NUL byte
|
|
|
d7a338 |
@@ -230,8 +233,11 @@ add_prog_path(char * buf, int b_sz, char const * fname, char const * prg_path)
|
|
|
d7a338 |
* Concatenate the file name to the end of the executable path.
|
|
|
d7a338 |
* The result may be either a file or a directory.
|
|
|
d7a338 |
*/
|
|
|
d7a338 |
- if (dir_len + fname_len > (unsigned)b_sz)
|
|
|
d7a338 |
+ if (dir_len + fname_len > (unsigned)b_sz) {
|
|
|
d7a338 |
+ if (path != prg_path)
|
|
|
d7a338 |
+ AGFREE(path);
|
|
|
d7a338 |
return false;
|
|
|
d7a338 |
+ }
|
|
|
d7a338 |
|
|
|
d7a338 |
memcpy(buf, path, dir_len);
|
|
|
d7a338 |
memcpy(buf + dir_len, fname, fname_len);
|
|
|
d7a338 |
--
|
|
|
d7a338 |
2.31.1
|
|
|
d7a338 |
|