From 5be91ad7b2876f17d700bddf388ed57f8536c2fd Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 29 Sep 2020 12:24:00 -0700 Subject: [PATCH] u3: tweaks u3s_jam_fib() call sites, correcting byte-length calculation --- pkg/urbit/noun/jets.c | 11 ++++------- pkg/urbit/tests/jam_tests.c | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/pkg/urbit/noun/jets.c b/pkg/urbit/noun/jets.c index 68dd54e15..4085f06a3 100644 --- a/pkg/urbit/noun/jets.c +++ b/pkg/urbit/noun/jets.c @@ -122,15 +122,12 @@ _cj_bash(u3_noun bat) } else { u3i_slab sab_u; - c3_w met_w; - c3_y* fat_y; - c3_y dig_y[32]; - - u3s_jam_fib(&sab_u, bat); + c3_w bit_w = u3s_jam_fib(&sab_u, bat); + c3_w met_w = (bit_w + 0x7) >> 3; // XX assumes little-endian // - fat_y = sab_u.buf_y; - met_w = sab_u.byt_d; + c3_y* fat_y = sab_u.buf_y; + c3_y dig_y[32]; #if defined(U3_OS_osx) CC_SHA256_CTX ctx_h; diff --git a/pkg/urbit/tests/jam_tests.c b/pkg/urbit/tests/jam_tests.c index 6d6d99cd0..3d9c367ea 100644 --- a/pkg/urbit/tests/jam_tests.c +++ b/pkg/urbit/tests/jam_tests.c @@ -341,7 +341,7 @@ _test_jam_spec(const c3_c* cap_c, u3i_slab sab_u; c3_w bit_w = u3s_jam_fib(&sab_u, ref); - out_d = sab_u.byt_d; + out_d = ((c3_d)bit_w + 0x7) >> 3; // XX assumes little-endian // out_y = sab_u.buf_y;