Compare commits

..

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
eac827f0e5
!69 [sync] PR-68: fix dbm_open error when the dir file is missing
From: @openeuler-sync-bot 
Reviewed-by: @liuzhiqiang26 
Signed-off-by: @liuzhiqiang26
2023-03-17 11:43:40 +00:00
wangzhiqiang
c5d7a9cf1e Minor fix in the compatibility library.
Signed-off-by: wangzhiqiang <wangzhiqiang95@huawei.com>
(cherry picked from commit 3715862511e40e92ca8a6f5e5e8fe8a093d8b302)
2023-03-17 19:33:19 +08:00
openeuler-ci-bot
bf1cd7dc27
!67 update to version 1.23
From: @foolstrong 
Reviewed-by: @liuzhiqiang26 
Signed-off-by: @liuzhiqiang26
2022-12-22 06:29:49 +00:00
wangzhiqiang
b124ff7b1c update to version 1.23
Signed-off-by: wangzhiqiang <wangzhiqiang95@huawei.com>
2022-12-20 20:30:30 +08:00
openeuler-ci-bot
6d207ab0fa
!62 fix allocated memory no released
From: @yangchen_guang 
Reviewed-by: @liuzhiqiang26 
Signed-off-by: @liuzhiqiang26
2022-08-30 02:44:32 +00:00
yangchenguang
13f9904980 fix allocated memory no released 2022-08-30 10:29:36 +08:00
openeuler-ci-bot
89ce394262
!57 Improve handling of -u in gdbm_load
From: @foolstrong 
Reviewed-by: @liuzhiqiang26 
Signed-off-by: @liuzhiqiang26
2022-07-05 07:09:29 +00:00
wangzhiqiang
46677b0d7a Improve handling of -u in gdbm_load
Signed-off-by: wangzhiqiang <wangzhiqiang95@huawei.com>
2022-07-05 09:15:36 +08:00
openeuler-ci-bot
79149e295b
!54 Fix semantics of gdbm_load -r
fix https://gitee.com/src-openeuler/gdbm/issues/I5FA4V
使用-r时必须指定-U参数,逐条读取dump文件中的key,若数据库中已存在该key,则覆盖此条数据,对于数据库中的其他数据,则保留。
不使用-r时,将会清空数据库中所有的数据,然后把dump文件中的数据逐条写入
![输入图片说明](https://images.gitee.com/uploads/images/2022/0704/144022_635e16ea_8080932.png "-r.PNG")

单独使用-r会报错
![输入图片说明](https://images.gitee.com/uploads/images/2022/0704/152717_6d6503dd_8080932.png "-r1.PNG") 
From: @foolstrong 
Reviewed-by: @liuzhiqiang26 
Signed-off-by: @liuzhiqiang26
2022-07-04 13:54:54 +00:00
wangzhiqiang
aa7bfd766e Fix semantics of gdbm_load -r
Signed-off-by: wangzhiqiang <wangzhiqiang95@huawei.com>
2022-07-04 17:16:18 +08:00
13 changed files with 459 additions and 109 deletions

View File

@ -0,0 +1,44 @@
From 1f10d92214e3f6f23b8d00dccafb5ad57856fbbd Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff <gray@gnu.org>
Date: Sat, 18 Jun 2022 17:35:35 +0300
Subject: [PATCH] Fix https://puszcza.gnu.org.ua/bugs/index.php?563
---
tools/gdbmshell.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/gdbmshell.c b/tools/gdbmshell.c
index 20c6ea9..1f61b5b 100644
--- a/tools/gdbmshell.c
+++ b/tools/gdbmshell.c
@@ -1328,6 +1328,7 @@ snapshot_handler (struct command_param *param, struct command_environ *cenv)
char *sb = tildexpand (PARAM_STRING (param, 1));
char const *sel;
int rc = gdbm_latest_snapshot (sa, sb, &sel);
+ int res;
if (rc >= 0 && rc < ARRAY_SIZE (snapshot_status_info))
{
@@ -1339,13 +1340,17 @@ snapshot_handler (struct command_param *param, struct command_environ *cenv)
snapshot_status_info[rc].fn (cenv->fp, sa, sb);
if (rc == GDBM_SNAPSHOT_OK)
print_snapshot (sel, cenv->fp);
+ res = GDBMSHELL_OK;
}
else
{
terror (_("unexpected error code: %d"), rc);
- return GDBMSHELL_ERR;
+ res = GDBMSHELL_ERR;
}
- return GDBMSHELL_OK;
+
+ free (sa);
+ free (sb);
+ return res;
}
--
2.33.0

View File

@ -1,7 +1,8 @@
From 94d0a6238e9573473d2cfdc74135305b2f6741f2 Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff <gray@gnu.org>
Date: Thu, 9 Jun 2022 22:44:26 +0300
Subject: [PATCH] Fix binary dump format for key and/or data of zero size.
Subject: [PATCH 05/14] Fix binary dump format for key and/or data of zero
size.
Fixes https://puszcza.gnu.org.ua/bugs/?565
@ -57,5 +58,5 @@ index be98ed7..73c0b74 100644
ec = GDBM_FILE_READ_ERROR;
break;
--
2.27.0
2.33.0

View File

@ -1,22 +1,19 @@
From d3f504875cb94d2e458e1e233e5ab8b40281fe2b Mon Sep 17 00:00:00 2001
From c25c66f3194f9c75483e550832d65d6554b22ec8 Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff <gray@gnu.org>
Date: Mon, 27 Jun 2022 11:49:31 +0300
Subject: [PATCH] Fix bug#569
Subject: [PATCH] Fix bug #569
* src/gdbmshell.c (input_history_begin): return GDBMSHELL_ERR
* tools/gdbmshell.c (input_history_begin): return GDBMSHELL_ERR
if history is not available.
Conflict: tools/gdbmshell.c --> src/gdbmshell.c
Reference: https://puszcza.gnu.org.ua/bugs/index.php?569
---
src/gdbmshell.c | 2 +-
tools/gdbmshell.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/gdbmshell.c b/src/gdbmshell.c
index 4b84c23..12fc2bd 100644
--- a/src/gdbmshell.c
+++ b/src/gdbmshell.c
@@ -1714,7 +1714,7 @@ input_history_begin (struct command_param *param,
diff --git a/tools/gdbmshell.c b/tools/gdbmshell.c
index bccda41..20c6ea9 100644
--- a/tools/gdbmshell.c
+++ b/tools/gdbmshell.c
@@ -1892,7 +1892,7 @@ input_history_begin (struct command_param *param,
/* TRANSLATORS: %s is the stream name */
terror (_("input history is not available for %s input stream"),
input_stream_name ());
@ -26,5 +23,5 @@ index 4b84c23..12fc2bd 100644
switch (param->argc)
--
1.8.3.1
2.33.0

View File

@ -1,45 +0,0 @@
From f3c7872fed5e0782438d186ac88c63035a637462 Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff <gray@gnu.org>
Date: Thu, 18 Nov 2021 12:22:59 +0200
Subject: Fix gdbmtool import command
* src/gdbmshell.c (import_handler): Fix option addressing (see
https://puszcza.gnu.org.ua/bugs/?535).
Fix freeing of the uninitialized variable.
---
src/gdbmshell.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/gdbmshell.c b/src/gdbmshell.c
index 08042ce..96b5844 100644
--- a/src/gdbmshell.c
+++ b/src/gdbmshell.c
@@ -661,7 +661,7 @@ err_printer (void *data GDBM_ARG_UNUSED, char const *fmt, ...)
fprintf (stderr, "\n");
}
-/* recover sumamry verbose backup max-failed-keys=N max-failed-buckets=N max-failures=N */
+/* recover summary verbose backup max-failed-keys=N max-failed-buckets=N max-failures=N */
static int
recover_handler (struct command_param *param, struct command_environ *cenv)
{
@@ -1585,7 +1585,7 @@ import_handler (struct command_param *param,
int rc = GDBMSHELL_OK;
char *file_name;
- for (i = 0; i < param->argc; i++)
+ for (i = 1; i < param->argc; i++)
{
if (strcmp (PARAM_STRING (param, i), "replace") == 0)
flag = GDBM_REPLACE;
@@ -1637,7 +1637,6 @@ import_handler (struct command_param *param,
return GDBMSHELL_GDBM_ERR;
}
- free (file_name);
if (gdbm_setopt (gdbm_file, GDBM_GETDBNAME, &file_name, sizeof (file_name)))
{
dberror ("%s", "GDBM_GETDBNAME");
--
cgit v1.2.1

View File

@ -1,28 +1,28 @@
From b8271d89db991558e10c26d45d960bbc0257fa31 Mon Sep 17 00:00:00 2001
From b5801318089f1dd062d039661aed3c701f2943c8 Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff <gray@gnu.org>
Date: Sat, 18 Jun 2022 17:18:05 +0300
Subject: [PATCH] Fix location tracking in gdbmtool. Fix the recover command.
In particular, this addresses https://puszcza.gnu.org.ua/bugs/?566
* src/gdbmshell.c: Fix parameter parsing failure
* tools/gdbmshell.c: Fix parameter parsing failure
(recover_handler): Accept varargs
(command_tab): Use argdoc to provide help for varargs
(help_handler): Handle argdoc
* src/gram.y: Accept a single unadorned key=value pair as argument.
* tools/gram.y: Accept a single unadorned key=value pair as argument.
Conflict: Fix only the part that caused the problem
Origin Patch: https://git.gnu.org.ua/gdbm.git/commit/?id=b8271d89db991558e10c26d45d960bbc0257fa31
---
src/gdbmshell.c | 156 +++++++++++++++++++++++++++++++++++---------------------
src/gram.y | 8 +++
2 files changed, 106 insertions(+), 58 deletions(-)
tools/gdbmshell.c | 150 ++++++++++++++++++++++++++++------------------
tools/gram.y | 8 +++
2 files changed, 101 insertions(+), 57 deletions(-)
diff --git a/src/gdbmshell.c b/src/gdbmshell.c
index 9f0d06c..4b84c23 100644
--- a/src/gdbmshell.c
+++ b/src/gdbmshell.c
@@ -625,64 +625,95 @@ recover_handler (struct command_param *param, struct command_environ *cenv)
diff --git a/tools/gdbmshell.c b/tools/gdbmshell.c
index 22c4938..bccda41 100644
--- a/tools/gdbmshell.c
+++ b/tools/gdbmshell.c
@@ -668,64 +668,95 @@ recover_handler (struct command_param *param, struct command_environ *cenv)
gdbm_recovery rcvr;
int flags = 0;
int rc;
@ -165,7 +165,7 @@ index 9f0d06c..4b84c23 100644
}
}
@@ -1765,6 +1796,7 @@ struct command
@@ -1943,6 +1974,7 @@ struct command
int (*handler) (struct command_param *param, struct command_environ *cenv);
void (*end) (void *data);
struct argdef args[NARGS];
@ -173,7 +173,7 @@ index 9f0d06c..4b84c23 100644
int variadic;
enum command_repeat_type repeat;
char *doc;
@@ -1891,21 +1923,21 @@ static struct command command_tab[] = {
@@ -2073,21 +2105,21 @@ static struct command command_tab[] = {
},
{
.name = "recover",
@ -205,28 +205,22 @@ index 9f0d06c..4b84c23 100644
.repeat = REPEAT_NEVER,
},
{
@@ -2244,7 +2276,15 @@ help_handler (struct command_param *param GDBM_ARG_UNUSED,
@@ -2435,6 +2467,10 @@ help_handler (struct command_param *param GDBM_ARG_UNUSED,
{
wordwrap_printf (wf, " %s", gettext (cmd->args[i].name));
}
n += fprintf (fp, " %s", gettext (cmd->args[i].name));
}
-
+ for (i = 0; i < NARGS && cmd->argdoc[i]; i++)
+ for (i = 0; cmd->argdoc[i]; i++)
+ {
+ if (n >= CMDCOLS)
+ {
+ fputc ('\n', fp);
+ n = fprintf (fp, "%*.*s", optoff, optoff, "");
+ wordwrap_printf (wf, " %s", gettext (cmd->argdoc[i]));
+ }
+ n += fprintf (fp, " %s", gettext (cmd->argdoc[i]));
+ }
if (n < CMDCOLS)
fprintf (fp, "%*.s", CMDCOLS-n, "");
else
diff --git a/src/gram.y b/src/gram.y
index 561de89..156bb2c 100644
--- a/src/gram.y
+++ b/src/gram.y
@@ -140,6 +140,13 @@ arg : string
wordwrap_set_right_margin (wf, 0);
wordwrap_set_left_margin (wf, CMDCOLS);
diff --git a/tools/gram.y b/tools/gram.y
index 6b09152..b1360ae 100644
--- a/tools/gram.y
+++ b/tools/gram.y
@@ -149,6 +149,13 @@ arg : string
{
$$ = gdbmarg_string ($1, &@1);
}
@ -240,7 +234,7 @@ index 561de89..156bb2c 100644
| compound
{
$$ = gdbmarg_kvpair ($1, &@1);
@@ -175,6 +182,7 @@ kvpair : value
@@ -184,6 +191,7 @@ kvpair : value
| T_IDENT '=' value
{
$3->key = $1;
@ -249,5 +243,5 @@ index 561de89..156bb2c 100644
}
;
--
1.8.3.1
2.33.0

View File

@ -0,0 +1,149 @@
From 0591202918948d41e331094b283ff699ab916c54 Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff <gray@gnu.org>
Date: Fri, 1 Jul 2022 14:03:22 +0300
Subject: [PATCH 11/14] Fix semantics of gdbm_load -r
Fixes https://puszcza.gnu.org.ua/bugs/index.php?573
* tools/gdbm_load.c: New option: --update (-U)
The --replace (-r) option is valid only if used together with
--update.
* NEWS: Document changes.
* doc/gdbm.texi: Document changes.
---
NEWS | 13 ++++++++++++-
doc/gdbm.texi | 25 ++++++++++++++++++++++---
tools/gdbm_load.c | 20 ++++++++++++++++++--
3 files changed, 52 insertions(+), 6 deletions(-)
diff --git a/NEWS b/NEWS
index 16d8d2a..a0d16b1 100644
--- a/NEWS
+++ b/NEWS
@@ -1,8 +1,19 @@
-GNU dbm NEWS -- history of user-visible changes. 2022-02-04
+GNU dbm NEWS -- history of user-visible changes. 2022-07-01
Copyright (C) 1990-2022 Free Software Foundation, Inc.
See the end of file for copying conditions.
Please send gdbm bug reports to <bug-gdbm@gnu.org>.
+
+
+* New gdbm_load option: --update
+
+The --update (-U) option instructs gdbm_load to update an existing
+database, whose name is supplied by the second argument.
+
+* Fix semantics of gdbm_load -r
+
+The --replace (-r) is valid only when used together with --update.
+
Version 1.23, 2022-02-04
diff --git a/doc/gdbm.texi b/doc/gdbm.texi
index e34873f..4fa841f 100644
--- a/doc/gdbm.texi
+++ b/doc/gdbm.texi
@@ -3251,6 +3251,8 @@ symmetry). A special code @samp{all} stands for all available error codes.
In boolean context, the @code{true} value is equivalent to @samp{all},
and @code{false} (i.e. variable unset) is equivalent to @samp{-all}.
+
+This variable cannot be set from interactive sessions.
@end deftypevr
@deftypevr {gdbmtool variable} string errormask
@@ -4070,9 +4072,17 @@ must be given as the second argument.
In general, if two arguments are given, the second one is treated as
the name of the database to create, overriding the file name specified
-in the flat file.
+in the flat file. All existing keys will be removed from this
+database prior to loading from the dump. Use the @option{--update}
+(@option{-U}) option if it is not what you wish.
+
+When given the @option{--update} (@option{-U}) option,
+@command{gdbm_load} will update the existing database with the data
+from the dump. It will bail out if the dump contains a key that is
+already present in the database. To silently overwrite existing keys,
+use the @option{--replace} (@option{-r}) option.
-The utility understands the following command line arguments:
+The utility understands the following command line options:
@table @option
@@ -4098,7 +4108,16 @@ Do not restore file meta-data (ownership and mode) from the flat file.
@item -r
@itemx --replace
-Replace existing keys.
+Replace existing keys. This option can be used only together with
+@option{--update} (@option{-U}).
+
+@item -U
+@itemx --update
+Update an existing database. The database name must be given in the
+second argument to @command{gdbm_load}. The key/value pairs from the
+dump file will be added to that database, without removing the
+existing keys. To overwrite the existing keys from the dump file, use
+@option{--update --replace}.
@item -u @var{user}[:@var{group}]
@itemx --user=@var{user}[:@var{group}]
diff --git a/tools/gdbm_load.c b/tools/gdbm_load.c
index b4691c9..5d5e50e 100644
--- a/tools/gdbm_load.c
+++ b/tools/gdbm_load.c
@@ -32,8 +32,9 @@ gid_t owner_gid;
char *parseopt_program_doc = N_("load a GDBM database from a file");
char *parseopt_program_args = N_("FILE [DB_FILE]");
struct gdbm_option optab[] = {
- { 'r', "replace", NULL, N_("replace records in the existing database") },
+ { 'r', "replace", NULL, N_("replace records in the existing database (needs -U)") },
{ 'm', "mode", N_("MODE"), N_("set file mode") },
+ { 'U', "update", NULL, N_("update the existing database") },
{ 'u', "user", N_("NAME|UID[:NAME|GID]"), N_("set file owner") },
{ 'n', "no-meta", NULL, N_("do not attempt to set file meta-data") },
{ 'M', "mmap", NULL, N_("use memory mapping") },
@@ -139,6 +140,10 @@ main (int argc, char **argv)
}
break;
+ case 'U':
+ oflags = (oflags & ~GDBM_OPENMASK) | GDBM_WRCREAT;
+ break;
+
case 'u':
{
size_t len;
@@ -228,13 +233,24 @@ main (int argc, char **argv)
if (argc > 2)
{
- error (_("too many arguments; try `%s -h' for more info"), progname);
+ error (_("too many arguments; try `%s -h' for more info"));
+ exit (EXIT_USAGE);
+ }
+
+ if (replace && (oflags & GDBM_OPENMASK) != GDBM_WRCREAT)
+ {
+ error (_("-r is useless without -U"));
exit (EXIT_USAGE);
}
filename = argv[0];
if (argc == 2)
dbname = argv[1];
+ else if (oflags & GDBM_WRCREAT)
+ {
+ error (_("-U requires DB_FILE to be supplied"));
+ exit (EXIT_USAGE);
+ }
else
dbname = NULL;
--
2.33.0

View File

@ -0,0 +1,78 @@
From 4cfdc68fd862a4e80f42f14aa92cb25db08b2466 Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff <gray@gnu.org>
Date: Sat, 2 Jul 2022 19:29:47 +0300
Subject: [PATCH 12/14] Improve handling of -u in gdbm_load
* tools/gdbm_load.c (main): Imply the owner login group if owner name
is followed by a :, and the current login group otherwise.
* doc/gdbm.texi: Document changes.
---
doc/gdbm.texi | 13 ++++++++-----
tools/gdbm_load.c | 9 +++++++--
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/doc/gdbm.texi b/doc/gdbm.texi
index 4fa841f..037ae07 100644
--- a/doc/gdbm.texi
+++ b/doc/gdbm.texi
@@ -4119,13 +4119,16 @@ dump file will be added to that database, without removing the
existing keys. To overwrite the existing keys from the dump file, use
@option{--update --replace}.
-@item -u @var{user}[:@var{group}]
-@itemx --user=@var{user}[:@var{group}]
-Set file owner. The @var{user} can be either a valid user name or
+@item -u @var{owner}[:[@var{group}]]
+@itemx --user=@var{owner}[:[@var{group}]]
+Set file owner. The @var{owner} can be either a valid user name or
UID. Similarly, the @var{group} is either a valid group name or GID.
-If @var{group} is not given, the main group of @var{user} is used.
+If @var{group} is not given, the main group of @var{owner} is implied, if
+@var{owner} is followed by a @samp{:}, otherwise the login group of the
+current user is implied.
-User and group parts can be separated by a dot, instead of the colon.
+User and group parts can be separated by a dot, instead of the colon,
+but such usage is discouraged.
@item -h
@itemx --help
diff --git a/tools/gdbm_load.c b/tools/gdbm_load.c
index 5d5e50e..e7e2ab1 100644
--- a/tools/gdbm_load.c
+++ b/tools/gdbm_load.c
@@ -148,9 +148,10 @@ main (int argc, char **argv)
{
size_t len;
struct passwd *pw;
+ int delim;
len = strcspn (optarg, ".:");
- if (optarg[len])
+ if ((delim = optarg[len]) != 0)
optarg[len++] = 0;
pw = getpwnam (optarg);
if (pw)
@@ -187,7 +188,7 @@ main (int argc, char **argv)
}
}
}
- else
+ else if (delim)
{
if (!pw)
{
@@ -200,6 +201,10 @@ main (int argc, char **argv)
}
owner_gid = pw->pw_gid;
}
+ else
+ {
+ owner_gid = getgid();
+ }
meta_mask |= GDBM_META_MASK_OWNER;
}
break;
--
2.33.0

View File

@ -0,0 +1,60 @@
From 3e63a788d4c7b5cb1173937118135c2bcca35a02 Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff <gray@gnu.org>
Date: Fri, 3 Mar 2023 13:52:56 +0200
Subject: [PATCH] Minor fix in the compatibility library.
* compat/dbmopen.c (ndbm_open_dir_file0): Don't try to unlink
the 1.8-compatible dir file or create a missing one if the database
is being opened read-only.
---
compat/dbmopen.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/compat/dbmopen.c b/compat/dbmopen.c
index b11af98..cb979b5 100644
--- a/compat/dbmopen.c
+++ b/compat/dbmopen.c
@@ -81,12 +81,21 @@ ndbm_open_dir_file0 (const char *file_name, int pagfd, int mode)
{
if (st.st_dev == pagst.st_dev && st.st_ino == pagst.st_ino)
{
- if (unlink (file_name))
+ if (flags == O_RDONLY)
{
- if ((mode & GDBM_OPENMASK) == GDBM_READER)
- /* Ok, try to cope with it. */
- return pagfd;
- else if (errno != ENOENT)
+ /*
+ * Don't touch the link if the database is opened read-only.
+ * Return a meaningful file descriptor for the sake
+ * of those programs that compare it with pagfd trying
+ * to detect old GDBM versions (as Sendmail does).
+ */
+ if ((fd = open ("/dev/null", flags)) == -1)
+ gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, TRUE);
+ return fd;
+ }
+ else if (unlink (file_name))
+ {
+ if (errno != ENOENT)
{
gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, TRUE);
return -1;
@@ -138,6 +147,13 @@ ndbm_open_dir_file0 (const char *file_name, int pagfd, int mode)
return -1;
}
}
+ else if (flags == O_RDONLY)
+ {
+ /* See the comment above. */
+ if ((fd = open ("/dev/null", flags)) == -1)
+ gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, TRUE);
+ return fd;
+ }
/* File does not exist. Create it. */
fd = open (file_name, flags | O_CREAT, pagst.st_mode & 0777);
--
2.33.0

View File

@ -0,0 +1,53 @@
From 331f05ac9c58d358806fe1bcba88a01467ab0895 Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff <gray@gnu.org>
Date: Mon, 4 Jul 2022 13:41:43 +0300
Subject: [PATCH] Bugfix
* tools/gdbm_load.c (main): Restore accidentally removed parameter.
* tools/gdbmapp.h (GDBM_PRINTFLIKE): New macro
(gdbm_perror, sys_perror, error): Mark as printf-like.
---
tools/gdbm_load.c | 2 +-
tools/gdbmapp.h | 10 +++++++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/tools/gdbm_load.c b/tools/gdbm_load.c
index e7e2ab1..78ab6a8 100644
--- a/tools/gdbm_load.c
+++ b/tools/gdbm_load.c
@@ -238,7 +238,7 @@ main (int argc, char **argv)
if (argc > 2)
{
- error (_("too many arguments; try `%s -h' for more info"));
+ error (_("too many arguments; try `%s -h' for more info"), progname);
exit (EXIT_USAGE);
}
diff --git a/tools/gdbmapp.h b/tools/gdbmapp.h
index 1bccb3d..94c04f6 100644
--- a/tools/gdbmapp.h
+++ b/tools/gdbmapp.h
@@ -21,12 +21,16 @@
# include <locale.h>
#endif
+#ifndef GDBM_PRINTFLIKE
+# define GDBM_PRINTFLIKE(fmt,narg) __attribute__ ((__format__ (__printf__, fmt, narg)))
+#endif
+
extern const char *progname;
void set_progname (const char *arg);
-void gdbm_perror (const char *fmt, ...);
-void sys_perror (int code, const char *fmt, ...);
-void error (const char *fmt, ...);
+void gdbm_perror (const char *fmt, ...) GDBM_PRINTFLIKE(1,2);
+void sys_perror (int code, const char *fmt, ...) GDBM_PRINTFLIKE(2,3);
+void error (const char *fmt, ...) GDBM_PRINTFLIKE(1,2);
void verror (const char *fmt, va_list ap);
void *emalloc (size_t size);
--
2.33.0

Binary file not shown.

BIN
gdbm-1.23.tar.gz Normal file

Binary file not shown.

View File

@ -1,19 +1,23 @@
Name: gdbm
Version: 1.22
Release: 7
Version: 1.23
Release: 2
Epoch: 1
Summary: A library of database functions that work similar to the standard UNIX dbm
License: GPLv3+
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
Patch2: gdbm_dump-fix-command-line-error-detection.patch
Patch3: Fix-location-tracking-in-gdbmtool.-Fix-the-recover-c.patch
Patch4: Fix-coredump-in-gdbmtool-history-command.patch
Patch0: Fix-binary-dump-format-for-key-and-or-data-of-zero-s.patch
Patch1: gdbm_dump-fix-command-line-error-detection.patch
Patch2: Fix-location-tracking-in-gdbmtool.-Fix-the-recover-c.patch
Patch3: Fix-coredump-in-gdbmtool-history-command.patch
Patch4: Fix-semantics-of-gdbm_load-r.patch
Patch5: Improve-handling-of-u-in-gdbm_load.patch
Patch6: Fix-allocated-memory-not-released.patch
Patch7: Restore-accidentally-removed-parameter-and-New-macro.patch
Patch8: Minor-fix-in-the-compatibility-library.patch
BuildRequires: gcc libtool gettext readline-devel bison flex
BuildRequires: gcc libtool gettext readline-devel bison flex texinfo
Provides: %{name}-libs
Provides: %{name}-libs%{?_isa}
@ -103,6 +107,21 @@ fi
%{_infodir}/*.info*
%changelog
* Thu Mar 16 2023 wangzhiqiang <wangzhiqiang95@huawei.com> - 1:1.23-2
- DESC:backport upstream patch
* Thu Dec 8 2022 wangzhiqiang <wangzhiqiang95@huawei.com> - 1:1.23-1
- DESC: update to version 1.23
* Tue Aug 30 2022 yangchenguang <yangchenguang@uniontech.com> - 1:1.22-10
- DESC: Fix allocated memory not released
* Tue Jul 5 2022 wangzhqiang <wangzhiqiang95@huawei.com> - 1:1.22-9
- DESC: Improve handling of -u in gdbm_load
* Mon Jul 4 2022 wangzhqiang <wangzhiqiang95@huawei.com> - 1:1.22-8
- DESC: Fix semantics of gdbm_load -r
* Tue Jun 28 2022 wangzhqiang <wangzhiqiang95@huawei.com> - 1:1.22-7
- DESC: Fix coredump in gdbmtool history command

View File

@ -1,17 +1,17 @@
From c96c160375bd1f3861651311e8645fb6478a1ffd Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff <gray@gnu.org>
Date: Mon, 20 Jun 2022 11:50:46 +0300
Subject: [PATCH] gdbm_dump: fix command line error detection
Subject: [PATCH 09/14] gdbm_dump: fix command line error detection
This fixes https://puszcza.gnu.org.ua/bugs/?567
---
src/gdbm_dump.c | 23 +++++++++++++++++------
tools/gdbm_dump.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/src/gdbm_dump.c b/src/gdbm_dump.c
diff --git a/tools/gdbm_dump.c b/tools/gdbm_dump.c
index a480152..2f37eac 100644
--- a/src/gdbm_dump.c
+++ b/src/gdbm_dump.c
--- a/tools/gdbm_dump.c
+++ b/tools/gdbm_dump.c
@@ -57,19 +57,31 @@ main (int argc, char **argv)
format = GDBM_DUMP_FMT_ASCII;
else
@ -68,5 +68,5 @@ index a480152..2f37eac 100644
}
-
--
1.8.3.1
2.33.0