diff options
author | Ángel González <[email protected]> | 2024-02-04 23:30:02 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2024-02-05 06:54:14 +0000 |
commit | 375c3a238ab67be9d52d1c4436f9855324c3f5dd (patch) | |
tree | e175830ed450a2e4e554bf62f2686633d9491c47 /sm | |
parent | scd:openpgp: Allow PIN length of 6 also with a reset code. (diff) | |
download | gnupg-375c3a238ab67be9d52d1c4436f9855324c3f5dd.tar.gz gnupg-375c3a238ab67be9d52d1c4436f9855324c3f5dd.zip |
gpgsm: cleanup on error paths
* sm/minip12.c (p12_parse): set err on the different error paths
--
GnuPG-bug-id: 6973
Fixes-commit: 101433dfb42b333e48427baf9dd58ac4787c9786
Signed-off-by: Ángel González <[email protected]>
Diffstat (limited to 'sm')
-rw-r--r-- | sm/minip12.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/sm/minip12.c b/sm/minip12.c index 2e7b50e1c..84a5f423c 100644 --- a/sm/minip12.c +++ b/sm/minip12.c @@ -1945,43 +1945,46 @@ p12_parse (const unsigned char *buffer, size_t length, const char *pw, } where = "pfx"; - if (tlv_next (tlv)) + if ((err = tlv_next (tlv))) goto bailout; - if (tlv_expect_sequence (tlv)) + if ((err = tlv_expect_sequence (tlv))) goto bailout; where = "pfxVersion"; - if (tlv_next (tlv)) + if ((err = tlv_next (tlv))) goto bailout; - if (tlv_expect_integer (tlv, &intval) || intval != 3) + if ((err = tlv_expect_integer (tlv, &intval)) || intval != 3) goto bailout; where = "authSave"; - if (tlv_next (tlv)) + if ((err = tlv_next (tlv))) goto bailout; - if (tlv_expect_sequence (tlv)) + if ((err = tlv_expect_sequence (tlv))) goto bailout; - if (tlv_next (tlv)) + if ((err = tlv_next (tlv))) goto bailout; - if (tlv_expect_object_id (tlv, &oid, &oidlen)) + if ((err = tlv_expect_object_id (tlv, &oid, &oidlen))) goto bailout; if (oidlen != DIM(oid_data) || memcmp (oid, oid_data, DIM(oid_data))) - goto bailout; + { + err = gpg_error (GPG_ERR_INV_OBJ); + goto bailout; + } - if (tlv_next (tlv)) + if ((err = tlv_next (tlv))) goto bailout; - if (tlv_expect_context_tag (tlv, &intval) || intval != 0 ) + if ((err = tlv_expect_context_tag (tlv, &intval)) || intval != 0 ) goto bailout; - if (tlv_next (tlv)) + if ((err = tlv_next (tlv))) goto bailout; - if (tlv_expect_octet_string (tlv, 1, NULL, NULL)) + if ((err = tlv_expect_octet_string (tlv, 1, NULL, NULL))) goto bailout; if (tlv_peek (tlv, CLASS_UNIVERSAL, TAG_OCTET_STRING)) { - if (tlv_next (tlv)) + if ((err = tlv_next (tlv))) goto bailout; err = tlv_expect_octet_string (tlv, 1, NULL, NULL); if (err) @@ -1989,9 +1992,9 @@ p12_parse (const unsigned char *buffer, size_t length, const char *pw, } where = "bags"; - if (tlv_next (tlv)) + if ((err = tlv_next (tlv))) goto bailout; - if (tlv_expect_sequence (tlv)) + if ((err = tlv_expect_sequence (tlv))) goto bailout; startlevel = tlv_parser_level (tlv); @@ -2000,12 +2003,12 @@ p12_parse (const unsigned char *buffer, size_t length, const char *pw, { where = "bag-sequence"; tlv_parser_dump_state (where, NULL, tlv); - if (tlv_expect_sequence (tlv)) + if ((err = tlv_expect_sequence (tlv))) goto bailout; - if (tlv_next (tlv)) + if ((err = tlv_next (tlv))) goto bailout; - if (tlv_expect_object_id (tlv, &oid, &oidlen)) + if ((err = tlv_expect_object_id (tlv, &oid, &oidlen))) goto bailout; if (oidlen == DIM(oid_encryptedData) |