Skip to content

Commit

Permalink
andOTP format: Avoid NULL+0 UB
Browse files Browse the repository at this point in the history
See #5476
  • Loading branch information
solardiz committed May 17, 2024
1 parent 08e2241 commit 5c936f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/aes_gcm_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ static void aes_gcm_ghash(const uint8_t *H, const uint8_t *aad, size_t aad_len,
}


#if 0
/**
* aes_gcm_ae - GCM-AE_K(IV, P, A)
*/
Expand Down Expand Up @@ -324,6 +325,7 @@ int aes_gcm_ae(const uint8_t *key, size_t key_len, const uint8_t *iv, size_t iv_

return 0;
}
#endif


/**
Expand Down Expand Up @@ -361,12 +363,14 @@ int aes_gcm_ad(const uint8_t *key, size_t key_len, const uint8_t *iv, size_t iv_
}


#if 0
int aes_gmac(const uint8_t *key, size_t key_len, const uint8_t *iv, size_t iv_len,
const uint8_t *aad, size_t aad_len, uint8_t *tag)
{
return aes_gcm_ae(key, key_len, iv, iv_len, NULL, 0, aad, aad_len, NULL,
tag);
}
#endif


#ifdef TEST
Expand Down
3 changes: 2 additions & 1 deletion src/andotp_fmt_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ static int check_password(int index, struct custom_salt *cs)
SHA256_Update(&ctx, saved_key[index], saved_len[index]);
SHA256_Final(key, &ctx);

ret = aes_gcm_ad(key, 32, cs->iv, IVLEN, cs->ciphertext, cs->ctlen, NULL, 0, cur_salt->tag, NULL, 1);
void *empty = ∅ /* Could be NULL, but we'd end up with NULL+0, which is UB */
ret = aes_gcm_ad(key, 32, cs->iv, IVLEN, cs->ciphertext, cs->ctlen, empty, 0, cur_salt->tag, empty, 1);

if (!ret)
return 1;
Expand Down

0 comments on commit 5c936f3

Please sign in to comment.