summaryrefslogtreecommitdiff
path: root/src/irmd/oap/hdr.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2026-07-10 17:09:58 +0200
committerSander Vrijders <sander@ouroboros.rocks>2026-07-19 11:44:35 +0200
commitaa28f5bf5bd92e69c0e89a1a36c7c95f28b7057c (patch)
tree90600bc702de0ee105c988bf5c792f324e0eab31 /src/irmd/oap/hdr.c
parentde9c30b2071e4aff8819d29c03d98767c8a3ec5b (diff)
downloadouroboros-aa28f5bf5bd92e69c0e89a1a36c7c95f28b7057c.tar.gz
ouroboros-aa28f5bf5bd92e69c0e89a1a36c7c95f28b7057c.zip
irmd: Avoid in-place byteswap in OAP header
gcc 12 -fanalyzer misclassifies kex_len = hton16(kex_len) followed by memcpy(&kex_len) as a read of an uninitialized value. Write the swapped value through the scratch variable like every other field in write_oap_fixed(). Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/irmd/oap/hdr.c')
-rw-r--r--src/irmd/oap/hdr.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/irmd/oap/hdr.c b/src/irmd/oap/hdr.c
index 6f355133..0cff345c 100644
--- a/src/irmd/oap/hdr.c
+++ b/src/irmd/oap/hdr.c
@@ -292,9 +292,9 @@ static void write_oap_fixed(uint8_t * buf,
kex_len |= OAP_KEX_ROLE_BIT;
}
- kex_len = hton16(kex_len);
- memcpy(buf + offset, &kex_len, sizeof(kex_len));
- offset += sizeof(kex_len);
+ v = hton16(kex_len);
+ memcpy(buf + offset, &v, sizeof(v));
+ offset += sizeof(v);
v = hton16((uint16_t) data_len);
memcpy(buf + offset, &v, sizeof(v));