From: tb Date: Wed, 10 Aug 2022 07:58:04 +0000 (+0000) Subject: Fix two compiler warnings resulting from last zlib bump X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=4df87382b989ef8c78487fb96522802d8f8861e9;p=openbsd Fix two compiler warnings resulting from last zlib bump total_out is now an unsigned long, so a format string warning is issued on all architectures. Fix this and also fix the format string for the off_t len, which is signed, not unsigned. Comparing an unsigned long to an off_t involves implementation-defined behavior for values > LONG_MAX on 64-bit architectures, so the compiler complains. Fix this by checking that len >= 0 and then casting both sides to a wider type. reported by and ok deraadt --- diff --git a/usr.bin/ctfdump/ctfdump.c b/usr.bin/ctfdump/ctfdump.c index 945cfc88a81..62d7a13b988 100644 --- a/usr.bin/ctfdump/ctfdump.c +++ b/usr.bin/ctfdump/ctfdump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ctfdump.c,v 1.25 2022/02/10 23:40:09 bluhm Exp $ */ +/* $OpenBSD: ctfdump.c,v 1.26 2022/08/10 07:58:04 tb Exp $ */ /* * Copyright (c) 2016 Martin Pieuchot @@ -699,8 +699,8 @@ decompress(const char *buf, size_t size, off_t len) goto exit; } - if (stream.total_out != len) { - warnx("decompression failed: %llu != %llu", + if (len < 0 || (uintmax_t)stream.total_out != (uintmax_t)len) { + warnx("decompression failed: %lu != %lld", stream.total_out, len); goto exit; }