Skip to content

ubsan - #763

Open
MarekKnapek wants to merge 16 commits into
libtom:developfrom
MarekKnapek:ubsan
Open

ubsan#763
MarekKnapek wants to merge 16 commits into
libtom:developfrom
MarekKnapek:ubsan

Conversation

@MarekKnapek

Copy link
Copy Markdown
Contributor

Checklist

  • documentation is added or updated
  • tests are added or updated
  • if this fixes something: added a Fixes: tag to the commit message

src/encauth/siv/siv.c:164:19: runtime error: null pointer passed as argument 2, which is declared to never be null
/usr/include/string.h:44:28: note: nonnull attribute specified here
src/misc/compare_testvector.c:63:25: runtime error: null pointer passed as argument 2, which is declared to never be null
/usr/include/string.h:65:33: note: nonnull attribute specified here
src/pk/ec25519/tweetnacl.c:56:12: runtime error: left shift of negative value -1
src/pk/ec25519/tweetnacl.c:369:21: runtime error: left shift of negative value -666
src/pk/ec448/ec448_common.c:257:17: runtime error: left shift of negative value -239381151
src/pk/ec448/ec448_common.c:99:17: runtime error: left shift of negative value -216193609
src/pk/ec448/ec448_common.c:105:15: runtime error: left shift of negative value -1
src/modes/ctr/ctr_encrypt.c:56:66: runtime error: load of misaligned address 0x7ffea07ee82f for type 'LTC_FAST_TYPE', which requires 8 byte alignment
src/modes/ctr/ctr_encrypt.c:56:64: runtime error: store to misaligned address 0x7ffea07ee82f for type 'LTC_FAST_TYPE', which requires 8 byte alignment
tests/store_test.c:66:91: runtime error: load of misaligned address 0x7ffdd32f0d9f for type 'LTC_FAST_TYPE', which requires 8 byte alignment
tests/store_test.c:66:52: runtime error: load of misaligned address 0x7ffdd32f0d71 for type 'LTC_FAST_TYPE', which requires 8 byte alignment
tests/store_test.c:66:50: runtime error: store to misaligned address 0x7ffdd32f0dc1 for type 'LTC_FAST_TYPE', which requires 8 byte alignment
src/mac/pmac/pmac_process.c:40:50: runtime error: load of misaligned address 0x57c89c4329ec for type 'LTC_FAST_TYPE', which requires 8 byte alignment
src/mac/xcbc/xcbc_process.c:35:60: runtime error: load of misaligned address 0x57c89c432ccc for type 'LTC_FAST_TYPE', which requires 8 byte alignment
src/mac/f9/f9_process.c:39:58: runtime error: load of misaligned address 0x5c2b1a1d2c14 for type 'LTC_FAST_TYPE', which requires 8 byte alignment
src/encauth/gcm/gcm_process.c:82:58: runtime error: load of misaligned address 0x596b3e6aa354 for type 'LTC_FAST_TYPE', which requires 8 byte alignment
As it might be dangerous to use it.
@karel-m

karel-m commented Jul 30, 2026

Copy link
Copy Markdown
Member

@MarekKnapek how is this PR different from #756 ?

@MarekKnapek

Copy link
Copy Markdown
Contributor Author

Eh, when talking about undefined behavior in #758 I decided to compile all of libtomcrypt with UBSan and fix all places it triggered during unit tests. Both PRs seem to be created roughly at the same time. This PR might contain more changes as it not only fixes the unaligned integer casts, but also some other things UBSan detected. Such as memcpy on null pointer and zero length. Bit-shift on singed negative variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants