diff options
author | Werner Koch <[email protected]> | 2018-07-27 15:35:00 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2018-07-27 15:48:18 +0000 |
commit | e88f56f1937ac92f6a3b94e50b6db2649ec0be41 (patch) | |
tree | c0a63a04aa104e9e1c755e6a9418750b6ed797a4 /g10/call-dirmngr.c | |
parent | dirmngr: Validate SRV records in WKD queries. (diff) | |
download | gnupg-e88f56f1937ac92f6a3b94e50b6db2649ec0be41.tar.gz gnupg-e88f56f1937ac92f6a3b94e50b6db2649ec0be41.zip |
gpg: Set a limit for a WKD import of 256 KiB.
* g10/call-dirmngr.c (MAX_WKD_RESULT_LENGTH): New.
(gpg_dirmngr_wkd_get): Use it.
--
WKD should return only a single key with just one UID. For key
rollover 2 keys may be send. A total of 256 KiB seems to be a
generous limit here.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/call-dirmngr.c')
-rw-r--r-- | g10/call-dirmngr.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/g10/call-dirmngr.c b/g10/call-dirmngr.c index d77b90dec..11663b9b1 100644 --- a/g10/call-dirmngr.c +++ b/g10/call-dirmngr.c @@ -41,6 +41,12 @@ #include "call-dirmngr.h" +/* Keys retrieved from the web key directory should be small. There + * is only one UID and we can expect that the number of subkeys is + * reasonable. So we set a generous limit of 256 KiB. */ +#define MAX_WKD_RESULT_LENGTH (256 * 1024) + + /* Parameter structure used to gather status info. Note that it is * also used for WKD requests. */ struct ks_status_parm_s @@ -1367,7 +1373,7 @@ gpg_dirmngr_wkd_get (ctrl_t ctrl, const char *name, int quick, goto leave; } - parm.memfp = es_fopenmem (0, "rwb"); + parm.memfp = es_fopenmem (MAX_WKD_RESULT_LENGTH, "rwb"); if (!parm.memfp) { err = gpg_error_from_syserror (); @@ -1375,6 +1381,8 @@ gpg_dirmngr_wkd_get (ctrl_t ctrl, const char *name, int quick, } err = assuan_transact (ctx, line, dns_cert_data_cb, &parm, NULL, NULL, ks_status_cb, &stparm); + if (gpg_err_code (err) == GPG_ERR_ENOSPC) + err = gpg_error (GPG_ERR_TOO_LARGE); if (err) goto leave; |