aboutsummaryrefslogtreecommitdiffstats
path: root/tools/wks-util.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2018-12-04 15:00:49 +0000
committerWerner Koch <[email protected]>2018-12-05 07:48:10 +0000
commit80bf1f8901dcbbb2cb6cacc11cca98705ce8f59d (patch)
treec9c88521395e1b228a3c4f584e32d65fdf152155 /tools/wks-util.c
parentwks: Allow reading of --install-key arguments from stdin. (diff)
downloadgnupg-80bf1f8901dcbbb2cb6cacc11cca98705ce8f59d.tar.gz
gnupg-80bf1f8901dcbbb2cb6cacc11cca98705ce8f59d.zip
wks: Fix filter expression syntax flaw.
* tools/wks-util.c (wks_get_key, wks_filter_uid): The filter expression needs a space before the value. (install_key_from_spec_file): Replace es_getline by es_read_line and remove debug output. -- A value of starting with '<' was considered an invalid operator due to our tokenization method. Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit 0c36ec241d285545f286069843de4f663cd274a3)
Diffstat (limited to '')
-rw-r--r--tools/wks-util.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/wks-util.c b/tools/wks-util.c
index cc755fd5c..3e4870938 100644
--- a/tools/wks-util.c
+++ b/tools/wks-util.c
@@ -192,7 +192,7 @@ wks_get_key (estream_t *r_key, const char *fingerprint, const char *addrspec,
es_fputs ("Content-Type: application/pgp-keys\n"
"\n", key);
- filterexp = es_bsprintf ("keep-uid=%s=%s", exact? "uid":"mbox", addrspec);
+ filterexp = es_bsprintf ("keep-uid=%s= %s", exact? "uid":"mbox", addrspec);
if (!filterexp)
{
err = gpg_error_from_syserror ();
@@ -466,7 +466,7 @@ wks_filter_uid (estream_t *r_newkey, estream_t key, const char *uid,
es_fputs ("Content-Type: application/pgp-keys\n"
"\n", newkey);
- filterexp = es_bsprintf ("keep-uid=uid=%s", uid);
+ filterexp = es_bsprintf ("keep-uid=uid= %s", uid);
if (!filterexp)
{
err = gpg_error_from_syserror ();
@@ -864,6 +864,7 @@ install_key_from_spec_file (const char *fname)
estream_t fp;
char *line = NULL;
size_t linelen = 0;
+ size_t maxlen = 2048;
char *fields[2];
unsigned int lnr = 0;
@@ -878,11 +879,16 @@ install_key_from_spec_file (const char *fname)
goto leave;
}
- while (es_getline (&line, &linelen, fp) >= 0)
+ while (es_read_line (fp, &line, &linelen, &maxlen) > 0)
{
+ if (!maxlen)
+ {
+ err = gpg_error (GPG_ERR_LINE_TOO_LONG);
+ log_error ("error reading '%s': %s\n", fname, gpg_strerror (err));
+ goto leave;
+ }
lnr++;
trim_spaces (line);
- log_debug ("got line='%s'\n", line);
if (!*line || *line == '#')
continue;
if (split_fields (line, fields, DIM(fields)) < 2)