Commit dd0f515
Yury Kirsanov
clusterer_controller: guard the zero-length cipherstate passthrough
cl_ctr_send_join_req_pkt() sends Noise msg 1 with an empty authenticated
payload, passing payload = NULL, pl_len = 0. That reaches the no-key
passthrough in cl_ctr_cs_encrypt() as memcpy(ct, NULL, 0).
memcpy() declares both pointers nonnull, and passing NULL is undefined
even when the length is zero, so gcc-13 at -O9 inlines the whole chain
(send_join_req_pkt -> noise_write1 -> ss_encrypt_hash -> cs_encrypt),
proves the argument NULL and fails the build under -Werror=nonnull.
Skip the copy when there is nothing to copy, in both cs_encrypt() and
its cs_decrypt() counterpart, which has the same latent problem. No
behaviour change: the branch is only reachable before a key is mixed in,
and a zero-length copy moved no bytes anyway.1 parent 62d44b8 commit dd0f515
1 file changed
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1926 | 1926 | | |
1927 | 1927 | | |
1928 | 1928 | | |
1929 | | - | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
1930 | 1932 | | |
1931 | 1933 | | |
1932 | 1934 | | |
| |||
1937 | 1939 | | |
1938 | 1940 | | |
1939 | 1941 | | |
1940 | | - | |
| 1942 | + | |
1941 | 1943 | | |
1942 | 1944 | | |
1943 | 1945 | | |
| |||
0 commit comments