mirror of
https://github.com/libtom/libtomcrypt
synced 2026-08-25 20:26:07 -04:00
Allow processing of empty files.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
parent
b0894f683f
commit
2320e44205
2 changed files with 16 additions and 9 deletions
|
|
@ -213,9 +213,10 @@ int pem_decode_pkcs_filehandle(FILE *f, ltc_pka_key *k, const password_ctx *pw_c
|
|||
|
||||
int pem_decode_pkcs(const void *buf, unsigned long len, ltc_pka_key *k, const password_ctx *pw_ctx)
|
||||
{
|
||||
LTC_ARGCHK(buf != NULL);
|
||||
LTC_ARGCHK(len != 0);
|
||||
LTC_ARGCHK(buf != NULL || len == 0);
|
||||
LTC_ARGCHK(k != NULL);
|
||||
if (len == 0)
|
||||
return CRYPT_OK;
|
||||
{
|
||||
struct get_char g = pem_get_char_init(buf, len);
|
||||
return s_decode(&g, k, pw_ctx);
|
||||
|
|
|
|||
|
|
@ -541,11 +541,15 @@ static int s_parse_line(char *line, unsigned long *len, ltc_pka_key *key, char *
|
|||
static int s_read_authorized_keys(const void *buf, unsigned long len, ssh_authorized_key_cb cb, void *ctx)
|
||||
{
|
||||
char *s;
|
||||
int err;
|
||||
int err = CRYPT_OK;
|
||||
unsigned long clen = len;
|
||||
ltc_pka_key *key = XCALLOC(1, sizeof(*key));
|
||||
ltc_pka_key *key = NULL;
|
||||
char *comment = NULL;
|
||||
void *cpy = XMALLOC(len);
|
||||
void *cpy = NULL;
|
||||
if (clen == 0)
|
||||
return CRYPT_OK;
|
||||
key = XCALLOC(1, sizeof(*key));
|
||||
cpy = XMALLOC(len);
|
||||
if (key == NULL || cpy == NULL) {
|
||||
if (cpy)
|
||||
XFREE(cpy);
|
||||
|
|
@ -835,9 +839,10 @@ int ssh_read_authorized_keys_filehandle(FILE *f, ssh_authorized_key_cb cb, void
|
|||
|
||||
int pem_decode_openssh(const void *buf, unsigned long len, ltc_pka_key *k, const password_ctx *pw_ctx)
|
||||
{
|
||||
LTC_ARGCHK(buf != NULL);
|
||||
LTC_ARGCHK(len != 0);
|
||||
LTC_ARGCHK(buf != NULL || len == 0);
|
||||
LTC_ARGCHK(k != NULL);
|
||||
if (len == 0)
|
||||
return CRYPT_OK;
|
||||
{
|
||||
struct get_char g = pem_get_char_init(buf, len);
|
||||
return s_decode_openssh(&g, k, pw_ctx);
|
||||
|
|
@ -846,9 +851,10 @@ int pem_decode_openssh(const void *buf, unsigned long len, ltc_pka_key *k, const
|
|||
|
||||
int ssh_read_authorized_keys(const void *buf, unsigned long len, ssh_authorized_key_cb cb, void *ctx)
|
||||
{
|
||||
LTC_ARGCHK(buf != NULL);
|
||||
LTC_ARGCHK(len != 0);
|
||||
LTC_ARGCHK(buf != NULL || len == 0);
|
||||
LTC_ARGCHK(cb != NULL);
|
||||
if (len == 0)
|
||||
return CRYPT_OK;
|
||||
|
||||
return s_read_authorized_keys(buf, len, cb, ctx);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue