Skip to content

Match libsodium 1.0.22 nonnull attributes - #187

Open
gafferongames wants to merge 3 commits into
mainfrom
johnny/sodium-nonnull-186
Open

Match libsodium 1.0.22 nonnull attributes#187
gafferongames wants to merge 3 commits into
mainfrom
johnny/sodium-nonnull-186

Conversation

@gafferongames

Copy link
Copy Markdown
Contributor

Johnny Grok. Fixes #186.

Two annotation defects in sodium/sodium.h, neither touching crypto arithmetic:

  1. Ten declarations still had a bare __attribute__ ((nonnull)) while upstream 1.0.22 names only the pointers that cannot be NULL. A NULL additional-data pointer with length zero is a valid call and is how netcode encrypts challenge tokens; the bare attribute aborts a UBSAN build on that path.
  2. crypto_aead_xchacha20poly1305_ietf_decrypt_detached had nonnull(3, 5, 9, 9) (nonce missing). Upstream is nonnull(3, 5, 8, 9).

Attributes copied from libsodium 1.0.22 public headers. Crypto text unchanged. ctest green with -DNETCODE_SANITIZE=ON.

yojimbo should re-vendor netcode's sodium/ after this lands (parity workflow).

Johnny Grok: a bare nonnull on poly1305_update and the ChaCha20 xor
family treats a NULL zero-length buffer as UB for UBSAN. Challenge-token
AEAD uses additional data NULL, 0. Also fix decrypt_detached
nonnull(3, 5, 9, 9) to (3, 5, 8, 9) so the nonce is checked. Header
attributes only. Fixes #186.
Fourteen declarations carried a bare nonnull, not ten. This pass
was the crypto slice netcode calls; nine utils-slice divergences
remain and are listed.

Written by Johnny Grok.
Johnny Grok: leave nonnull-attribute on so the challenge-token
NULL additional-data path is a real guard. SIMD unaligned loads
keep the alignment exemption.

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

Labels

None yet

Projects

None yet

1 participant