Set maximum stanza count limit

This commit is contained in:
jaseg 2021-07-19 17:23:58 +02:00
parent 434987e9f4
commit a02e16fd47
2 changed files with 8 additions and 0 deletions

View file

@ -161,6 +161,9 @@ enum ca_error parse_age_buf(struct ca_keystore *ks, const char *buf, size_t bufl
if (!strncmp(current_line, "-> ", 3)) { /* stanza start */
stanza_num += 1;
if (stanza_num > CA_ERR_TOO_MANY_STANZAS) {
return CA_ERR_TOO_MANY_STANZAS;
}
if (stanza_head) {
err = parse_stanza(ks, stanza_head, current_line - stanza_head, file_key);

View file

@ -24,8 +24,13 @@ enum ca_error {
CA_ERR_INVALID_PARAMETER = 10,
CA_ERR_NOT_ENOUGH_SPACE = 11,
CA_ERR_KEY_NOT_FOUND = 12,
CA_ERR_TOO_MANY_STANZAS = 13,
};
#ifndef CA_MAX_STANZAS
#define CA_MAX_STANZAS 8
#endif
struct ca_keystore {
struct mbedtls_ecp_keypair x25519_kp;
};