From f868c4327d366a7e142e27ffbaa383d75aef6c1b Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Fri, 11 Oct 2019 23:15:42 +0100 Subject: [PATCH] struct/buf.c (buf_getmem*): Add an explicit `BENSURE'. Otherwise we fail when processing a 64-bit length on a 32-bit platform: an overlong 64-bit length gets truncated to a possibly-acceptable 32-bit length in the implicit conversion to `size_t' in the call to `buf_get'. Using `BENSURE' directly ensures that the comparison gets done with the correct integer type. --- struct/buf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/struct/buf.c b/struct/buf.c index d86904c..bd16ec7 100644 --- a/struct/buf.c +++ b/struct/buf.c @@ -247,6 +247,7 @@ static int findz(buf *b, size_t *nn) { \ uint##n sz; \ if (buf_getu##w(b, &sz)) return (0); \ + if (BENSURE(b, sz)) return (0); \ *nn = sz; \ return (buf_get(b, sz)); \ } -- 2.11.0