mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-21 12:02:19 +00:00
feat(crypto): Sanitize undefined behavior.
This commit is contained in:
parent
af0ae880a1
commit
d6fdadf673
@ -3,7 +3,7 @@ CC ?= clang
|
|||||||
LD ?= $(CC)
|
LD ?= $(CC)
|
||||||
SANFLAGS += -fsanitize=fuzzer
|
SANFLAGS += -fsanitize=fuzzer
|
||||||
else ifeq ($(ADDRESS_SANITIZER),1)
|
else ifeq ($(ADDRESS_SANITIZER),1)
|
||||||
SANFLAGS += -fsanitize=address
|
SANFLAGS += -fsanitize=address,undefined
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CC ?= gcc
|
CC ?= gcc
|
||||||
|
@ -688,6 +688,10 @@ groestl_big_init(sph_groestl_big_context *sc, unsigned out_size)
|
|||||||
static void
|
static void
|
||||||
groestl_big_core(sph_groestl_big_context *sc, const void *data, size_t len)
|
groestl_big_core(sph_groestl_big_context *sc, const void *data, size_t len)
|
||||||
{
|
{
|
||||||
|
if (len == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned char *buf = NULL;
|
unsigned char *buf = NULL;
|
||||||
size_t ptr = 0;
|
size_t ptr = 0;
|
||||||
DECL_STATE_BIG
|
DECL_STATE_BIG
|
||||||
|
@ -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)
|
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 idx = (size_t)ctx->rest;
|
||||||
size_t block_size = (size_t)ctx->block_size;
|
size_t block_size = (size_t)ctx->block_size;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
CC = gcc
|
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 =
|
LIBS =
|
||||||
INC = -I ../../../crypto -I ../.. -I .
|
INC = -I ../../../crypto -I ../.. -I .
|
||||||
BASE = ../../../
|
BASE = ../../../
|
||||||
|
Loading…
Reference in New Issue
Block a user