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
-/* $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 <mpi@openbsd.org>
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;
}