Skip to content

Commit

Permalink
cbits: Squash a Wstringop-overread error
Browse files Browse the repository at this point in the history
Pretty sure this warning is only generated with GCC versions >= 14.2.

A type and a function were defined as follows:

    typedef unsigned char ed25519_secret_key[64];
    void cardano_crypto_ed25519_publickey(const ed25519_secret_key sk, ed25519_public_key pk);

and then the code had:

    uint8_t zl8[32];
    cardano_crypto_ed25519_publickey(zl8, pub_zl8);

The compiler error was squashed by changing the type of `uint8_t [32]` to
`ed25519_secret_key` which is 64 bytes in size and then updating the
`memset` call to zero the whole array.
  • Loading branch information
erikd committed Oct 11, 2024
1 parent 35532ae commit 40c7183
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cbits/encrypted_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ static void serialize_index32(uint8_t *out, uint32_t index, derivation_scheme_mo

static void add_left(ed25519_secret_key res_key, uint8_t *z, ed25519_secret_key priv_key, derivation_scheme_mode mode)
{
uint8_t zl8[32];
ed25519_secret_key zl8;

memset(zl8, 0, 32);
memset(zl8, 0, 64);
switch (mode) {
case DERIVATION_V1:
/* get 8 * Zl */
Expand Down Expand Up @@ -287,10 +287,10 @@ static void add_right(ed25519_secret_key res_key, uint8_t *z, ed25519_secret_key

static void add_left_public(uint8_t *out, uint8_t *z, uint8_t *in, derivation_scheme_mode mode)
{
uint8_t zl8[32];
ed25519_secret_key zl8;
ed25519_public_key pub_zl8;

memset(zl8, 0, 32);
memset(zl8, 0, 64);
switch (mode) {
case DERIVATION_V1:
multiply8_v1(zl8, z, 32);
Expand Down

0 comments on commit 40c7183

Please sign in to comment.