diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-04-22 18:51:59 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-05-06 11:53:17 -0600 |
commit | 24e5d0ec1219e2dbb4b9510ef20833092a2b3871 (patch) | |
tree | 01bbcc34c6190fa1c35b2625e9ba1744b1447606 /cmd/sbc_harness/fs_harness_uptime_txt.c | |
parent | f09b7435b3a5222597d27238226d23ec0cbd5bd2 (diff) |
wip: Build with -Wconversionlukeshu/safe-conversion
I think this found a real bug in the dhcp packet parser.
I don't think anything called lib9p_str{,n}() values that could be big
enough, but their bounds-checking was broken.
Diffstat (limited to 'cmd/sbc_harness/fs_harness_uptime_txt.c')
-rw-r--r-- | cmd/sbc_harness/fs_harness_uptime_txt.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/cmd/sbc_harness/fs_harness_uptime_txt.c b/cmd/sbc_harness/fs_harness_uptime_txt.c index f7b755f..6e65f34 100644 --- a/cmd/sbc_harness/fs_harness_uptime_txt.c +++ b/cmd/sbc_harness/fs_harness_uptime_txt.c @@ -120,16 +120,16 @@ static void uptime_fio_pread(struct uptime_fio *self, struct lib9p_srv_ctx *ctx, if (byte_offset == 0 || self->buf_len == 0) { uint64_t now = LO_CALL(bootclock, get_time_ns); - self->buf_len = snprintf(self->buf, sizeof(self->buf), "%"PRIu64"ns\n", now); + self->buf_len = LM_SAFEDOWNCAST(size_t, snprintf(self->buf, sizeof(self->buf), "%"PRIu64"ns\n", now)); } - if (byte_offset > (uint64_t)self->buf_len) { + if (byte_offset > self->buf_len) { lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EINVAL, "offset is past end-of-file length"); return; } - size_t beg_off = (size_t)byte_offset; + size_t beg_off = LM_SAFEDOWNCAST(size_t, byte_offset); size_t end_off = beg_off + (size_t)byte_count; if (end_off > self->buf_len) end_off = self->buf_len; |