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

scd: Fix resource leaks on error paths.

* scd/app-dinsig.c (do_readcert): Don't return directly but care about
releasing memory.
* scd/app-nks.c (readcert_from_ef): Likewise.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2024-11-11 09:51:54 +09:00 committed by Werner Koch
parent e4d9fe0556
commit 1e28c55e11
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 13 additions and 4 deletions

View File

@ -226,7 +226,10 @@ do_readcert (app_t app, const char *certid,
else if ( class == CLASS_UNIVERSAL && tag == TAG_SET && constructed )
rootca = 1;
else
return gpg_error (GPG_ERR_INV_OBJ);
{
err = gpg_error (GPG_ERR_INV_OBJ);
goto leave;
}
totobjlen = objlen + hdrlen;
log_assert (totobjlen <= buflen);

View File

@ -999,7 +999,10 @@ readcert_from_ef (app_t app, int fid, unsigned char **cert, size_t *certlen)
else if ( class == CLASS_UNIVERSAL && tag == TAG_SET && constructed )
rootca = 1;
else
return gpg_error (GPG_ERR_INV_OBJ);
{
err = gpg_error (GPG_ERR_INV_OBJ);
goto leave;
}
totobjlen = objlen + hdrlen;
log_assert (totobjlen <= buflen);
@ -1030,7 +1033,10 @@ readcert_from_ef (app_t app, int fid, unsigned char **cert, size_t *certlen)
if (err)
goto leave;
if ( !(class == CLASS_UNIVERSAL && tag == TAG_SEQUENCE && constructed) )
return gpg_error (GPG_ERR_INV_OBJ);
{
err = gpg_error (GPG_ERR_INV_OBJ);
goto leave;
}
totobjlen = objlen + hdrlen;
log_assert (save_p + totobjlen <= buffer + buflen);
memmove (buffer, save_p, totobjlen);
@ -1144,7 +1150,7 @@ iterate_over_filelist (app_t app, const char *want_keygripstr, int capability,
continue;
}
/* Found. Return but save the last idenx of the loop. */
/* Found. Return but save the last index of the loop. */
*idx_p = idx;
return 0;
}