aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2020-11-02 17:23:53 +0100
committerWerner Koch <wk@gnupg.org>2020-11-02 17:34:29 +0100
commite1bafa3574ccd56d9f8f8c1deb3d8fb9fd7025cc (patch)
treeea99746f2866c52a3a0173238eef57bbda5e89ee
parent6397cf5fbe3bbc1f616431b011f76e031a387d4c (diff)
downloadgnupg-e1bafa3574ccd56d9f8f8c1deb3d8fb9fd7025cc.tar.gz
gpg: Allow setting notations with the empty string as value.
* g10/misc.c (pct_expando): Catch special case of the empty string. Also map a NULL to the empty string. * g10/photoid.c (show_photos): Make an empty string used as command fail. -- This patch also fixes a segv when calling gpg wrongly like gpg -N \-foo@example.org GnuPG-bug-id: 5117 Signed-off-by: Werner Koch <wk@gnupg.org>
-rw-r--r--g10/misc.c5
-rw-r--r--g10/photoid.c5
2 files changed, 10 insertions, 0 deletions
diff --git a/g10/misc.c b/g10/misc.c
index c7107be06..a606d5364 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -922,6 +922,11 @@ pct_expando (ctrl_t ctrl, const char *string,struct expando_args *args)
u32 pk_keyid[2]={0,0},sk_keyid[2]={0,0};
char *ret=NULL;
+ /* The parser below would return NULL for an empty string, thus we
+ * catch it here. Also catch NULL here. */
+ if (!string || !*string)
+ return xstrdup ("");
+
if(args->pk)
keyid_from_pk(args->pk,pk_keyid);
diff --git a/g10/photoid.c b/g10/photoid.c
index 8a4436b8b..592d5e484 100644
--- a/g10/photoid.c
+++ b/g10/photoid.c
@@ -670,6 +670,11 @@ show_photos (ctrl_t ctrl, const struct user_attribute *attrs, int count,
command = pct_expando (ctrl, opt.photo_viewer,&args);
if(!command)
goto fail;
+ if (!*command)
+ {
+ xfree (command);
+ goto fail;
+ }
name = xmalloc (1 + 16 + strlen(EXTSEP_S)
+ strlen (image_type_to_string (args.imagetype, 0)));