1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-17 05:03:07 +00:00

feat(crypto): Sanitize undefined behavior.

This commit is contained in:
Andrew Kozlik 2022-01-13 11:33:58 +01:00 committed by matejcik
parent af0ae880a1
commit d6fdadf673
4 changed files with 8 additions and 2 deletions

View File

@ -3,7 +3,7 @@ CC ?= clang
LD ?= $(CC)
SANFLAGS += -fsanitize=fuzzer
else ifeq ($(ADDRESS_SANITIZER),1)
SANFLAGS += -fsanitize=address
SANFLAGS += -fsanitize=address,undefined
endif
CC ?= gcc

View File

@ -688,6 +688,10 @@ groestl_big_init(sph_groestl_big_context *sc, unsigned out_size)
static void
groestl_big_core(sph_groestl_big_context *sc, const void *data, size_t len)
{
if (len == 0) {
return;
}
unsigned char *buf = NULL;
size_t ptr = 0;
DECL_STATE_BIG

View File

@ -283,6 +283,8 @@ static void sha3_process_block(uint64_t hash[25], const uint64_t *block, size_t
*/
void sha3_Update(SHA3_CTX *ctx, const unsigned char *msg, size_t size)
{
if (size == 0) return;
size_t idx = (size_t)ctx->rest;
size_t block_size = (size_t)ctx->block_size;

View File

@ -1,5 +1,5 @@
CC = gcc
CFLAGS = -Wall -Wshadow -Wextra -Wpedantic -Werror -Wno-missing-braces -fPIC -fsanitize=address
CFLAGS = -Wall -Wshadow -Wextra -Wpedantic -Werror -Wno-missing-braces -fPIC -fsanitize=address,undefined
LIBS =
INC = -I ../../../crypto -I ../.. -I .
BASE = ../../../