-
Notifications
You must be signed in to change notification settings - Fork 485
Closed
Milestone
Description
Description
Running under ubsan catches undefined behaviour in ctr_encrypt. The problem is that ctr->pad isn't 16 byte aligned, but we have a cast to a ulong64. I'm not sure how important it is for portability, I guess x64 works fine? Unsure the best way to fix it, other than just disabling LTC_FAST for that section - maybe the compiler will unroll it anyway...
ctr_encrypt.c:63 *(LTC_FAST_TYPE_PTR_CAST((unsigned char *)ctr->pad + x));Steps to Reproduce
make CC=clang CFLAGS="-fsanitize=undefined -fno-sanitize-recover=undefined -DUSE_LTM -DLTM_DESC" EXTRALIBS="-ltommath" LD=clang++ LDFLAGS=-fsanitize=undefined test
./test
...
store_test..........src/modes/ctr/ctr_encrypt.c:57:60: runtime error: load of misaligned address 0x000000eae01c for type 'LTC_FAST_TYPE' (aka 'unsigned long long'), which requires 8 byte alignment
0x000000eae01c: note: pointer points here
00 00 00 00 9e 26 81 83 ff ee e7 0b 2e 07 2e 5c 68 ee e6 29 00 00 00 00 00 00 00 00 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/modes/ctr/ctr_encrypt.c:57:60 in
Version
v1.18.2-595-gcfbd7f8d
Ubuntu 20.04, x64
clang 10.0.0-4ubuntu1
Metadata
Metadata
Assignees
Labels
No labels