1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

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 <angel@pgp.16bits.net>
This commit is contained in:
Ángel González 2024-02-05 00:30:02 +01:00 committed by Werner Koch
parent 40b85d8e8c
commit 375c3a238a
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -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)))
{
err = gpg_error (GPG_ERR_INV_OBJ);
goto bailout;
}
if ((err = tlv_next (tlv)))
goto bailout;
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_context_tag (tlv, &intval) || intval != 0 )
goto bailout;
if (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)