From 3a6f2fe84ac9bd29fb13967c61956b30e067517e Mon Sep 17 00:00:00 2001 From: wangzhiqiang Date: Wed, 22 Jun 2022 14:44:18 +0800 Subject: [PATCH] gdbm_dump fix command line error detection Signed-off-by: wangzhiqiang --- gdbm.spec | 8 ++- ...ump-fix-command-line-error-detection.patch | 72 +++++++++++++++++++ 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 gdbm_dump-fix-command-line-error-detection.patch diff --git a/gdbm.spec b/gdbm.spec index 7e1066e..3e8e2c3 100644 --- a/gdbm.spec +++ b/gdbm.spec @@ -1,6 +1,6 @@ Name: gdbm Version: 1.22 -Release: 4 +Release: 5 Epoch: 1 Summary: A library of database functions that work similar to the standard UNIX dbm License: GPLv3+ @@ -8,7 +8,8 @@ URL: http://www.gnu.org/software/gdbm/ Source0: http://ftp.gnu.org/gnu/gdbm/gdbm-%{version}.tar.gz Patch0: Fix-gdbmtool-import-command.patch -Patch1: Fix-binary-dump-format-for-key-and-or-data-of-zero-s.patch +Patch1: Fix-binary-dump-format-for-key-and-or-data-of-zero-s.patch +Patch2: gdbm_dump-fix-command-line-error-detection.patch BuildRequires: gcc libtool gettext readline-devel @@ -100,6 +101,9 @@ fi %{_infodir}/*.info* %changelog +* Wed Jun 22 2022 wangzhqiang - 1:1.22-5 +- DESC: gdbm_dump-fix-command-line-error-detection + * Fri Jun 17 2022 wangzhiqiang - 1:1.22-4 - DESC: Fix binary dump format for key and or data of zero size diff --git a/gdbm_dump-fix-command-line-error-detection.patch b/gdbm_dump-fix-command-line-error-detection.patch new file mode 100644 index 0000000..0e248e3 --- /dev/null +++ b/gdbm_dump-fix-command-line-error-detection.patch @@ -0,0 +1,72 @@ +From c96c160375bd1f3861651311e8645fb6478a1ffd Mon Sep 17 00:00:00 2001 +From: Sergey Poznyakoff +Date: Mon, 20 Jun 2022 11:50:46 +0300 +Subject: [PATCH] gdbm_dump: fix command line error detection + +This fixes https://puszcza.gnu.org.ua/bugs/?567 +--- + src/gdbm_dump.c | 23 +++++++++++++++++------ + 1 file changed, 17 insertions(+), 6 deletions(-) + +diff --git a/src/gdbm_dump.c b/src/gdbm_dump.c +index a480152..2f37eac 100644 +--- a/src/gdbm_dump.c ++++ b/src/gdbm_dump.c +@@ -57,19 +57,31 @@ main (int argc, char **argv) + format = GDBM_DUMP_FMT_ASCII; + else + { +- format = atoi (optarg); +- switch (format) ++ char *p; ++ unsigned long n; ++ ++ errno = 0; ++ n = strtoul (optarg, &p, 10); ++ if (errno || *p != 0) ++ { ++ error (_("unknown dump format")); ++ exit (EXIT_USAGE); ++ } ++ ++ switch (n) + { + case GDBM_DUMP_FMT_BINARY: + case GDBM_DUMP_FMT_ASCII: ++ format = n; + break; ++ + default: + error (_("unknown dump format")); + exit (EXIT_USAGE); + } + } + break; +- ++ + default: + error (_("unknown option")); + exit (EXIT_USAGE); +@@ -90,7 +102,7 @@ main (int argc, char **argv) + error (_("too many arguments; try `%s -h' for more info"), progname); + exit (EXIT_USAGE); + } +- ++ + dbname = argv[0]; + if (argc == 2) + filename = argv[1]; +@@ -124,9 +136,8 @@ main (int argc, char **argv) + { + gdbm_perror (_("dump error"), filename); + } +- ++ + gdbm_close (dbf); + + exit (rc == GDBM_NO_ERROR ? EXIT_OK : EXIT_FATAL); + } +- +-- +1.8.3.1 + -- Gitee