]> www.wagner.pp.ru Git - openssl-gost/engine.git/commit
Fix gcc13 error: writing 1 byte into a region of size 0
authorVitaly Chikunov <vt@altlinux.org>
Wed, 14 Jun 2023 14:12:51 +0000 (17:12 +0300)
committerDmitry Belyavskiy <beldmit@users.noreply.github.com>
Thu, 15 Jun 2023 14:08:53 +0000 (16:08 +0200)
commitaf20283d945d0607c2245e7f5871ee09c9024bc0
treeae3fb56e4d43bc8fb0bd303af41cc8e91de9f7b1
parent2b22503cf83c56f27719eccce013999203e69db0
Fix gcc13 error: writing 1 byte into a region of size 0

gcc-13 thinks `bl` can take negative value (when returned from
EVP_CIPHER_CTX_block_size). Do simple sanity checking to workaround this.
Also, add error propagation up to EVP_DigestFinal_ex, so this sanity checking
is not in vain.

Error message:

  In function 'make_kn',
      inlined from 'CMAC_ACPKM_Final' at /builddir/build/BUILD/engine-3.0.0/gost_omac_acpkm.c:274:5,
      inlined from 'omac_acpkm_imit_final' at /builddir/build/BUILD/engine-3.0.0/gost_omac_acpkm.c:354:5:
  /builddir/build/BUILD/engine-3.0.0/gost_omac_acpkm.c:55:20: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
     55 |         k1[bl - 1] ^= bl == 16 ? 0x87 : 0x1b;
        |         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
  /builddir/build/BUILD/engine-3.0.0/gost_omac_acpkm.c: In function 'omac_acpkm_imit_final':
  /builddir/build/BUILD/engine-3.0.0/gost_omac_acpkm.c:260:24: note: at offset [-2147483649, -1] into destination object 'k2' of size 32
    260 |     unsigned char *k1, k2[EVP_MAX_BLOCK_LENGTH];
        |                        ^~

Fixes: https://github.com/gost-engine/engine/issues/436
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
gost_omac_acpkm.c