diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2024-07-12 08:57:48 +0200 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2024-07-12 08:57:48 +0200 |
commit | cc78b26a4729db2280334214e21a8847e95d2ab0 (patch) | |
tree | e2b9f3e27880d5a3b03749b263d2fcf5e7f62486 /common/tlv-parser.c | |
parent | gpg: Fix agent_probe_any_secret_key. (diff) | |
download | gnupg2-cc78b26a4729db2280334214e21a8847e95d2ab0.tar.xz gnupg2-cc78b26a4729db2280334214e21a8847e95d2ab0.zip |
common: Fix tlv-parser for constructed OCTET-STRING.
* common/tlv-parser.c (tlv_expect_octet_string): Fix assignment of N
value.
--
Before the change, need_octet_string_cramming returns always false,
because N==0.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'common/tlv-parser.c')
-rw-r--r-- | common/tlv-parser.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/common/tlv-parser.c b/common/tlv-parser.c index 2cafac3e9..bc22c4f4f 100644 --- a/common/tlv-parser.c +++ b/common/tlv-parser.c @@ -556,7 +556,10 @@ tlv_expect_octet_string (tlv_parser_t tlv, int encapsulates, && (!tlv->ti.is_constructed || encapsulates))) return (tlv->lasterr = gpg_error (GPG_ERR_INV_OBJ)); p = tlv->buffer; - if (!(n=tlv->ti.length) && !tlv->ti.ndef) + n = tlv->ti.length; + if (!n && tlv->ti.ndef) + n = tlv->bufsize; + else if (!tlv->ti.length) return (tlv->lasterr = gpg_error (GPG_ERR_TOO_SHORT)); if (encapsulates && tlv->ti.is_constructed |