From 7c8b66d76b562912c09c0955a53da2f26afbc8f7 Mon Sep 17 00:00:00 2001 From: Sergio Gelato Date: Wed, 28 Sep 2016 15:15:12 +0200 Subject: [PATCH] Use off_t in for constants used in iprop log seeks On 32-bit architectures with _FILE_OFFSET_BITS=64, sizeof(off_t) > sizeof(size_t) . LOG_HEADER_SZ was #define'd as an expression of type size_t, so in order to get the sign extension right we need -(off_t)LOG_HEADER_SZ instead of (off_t)(-LOG_HEADER_SZ). However, we can just define the *_SZ macros to cast to off_t, then we don't need to worry about negation. Fixes Debian bug #822749, PR 175. Signed-off-by (and updated by): Nicolas Williams --- lib/kadm5/log.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/kadm5/log.c b/lib/kadm5/log.c index efe1f781c8..0f237fbd44 100644 --- a/lib/kadm5/log.c +++ b/lib/kadm5/log.c @@ -174,11 +174,11 @@ RCSID("$Id$"); * will deadlock with ipropd-slave -- don't do that. */ -#define LOG_HEADER_SZ (sizeof(uint32_t) * 4) -#define LOG_TRAILER_SZ (sizeof(uint32_t) * 2) -#define LOG_WRAPPER_SZ (LOG_HEADER_SZ + LOG_TRAILER_SZ) -#define LOG_UBER_LEN (sizeof(uint64_t) + sizeof(uint32_t) * 2) -#define LOG_UBER_SZ (LOG_WRAPPER_SZ + LOG_UBER_LEN) +#define LOG_HEADER_SZ ((off_t)(sizeof(uint32_t) * 4)) +#define LOG_TRAILER_SZ ((off_t)(sizeof(uint32_t) * 2)) +#define LOG_WRAPPER_SZ ((off_t)(LOG_HEADER_SZ + LOG_TRAILER_SZ)) +#define LOG_UBER_LEN ((off_t)(sizeof(uint64_t) + sizeof(uint32_t) * 2)) +#define LOG_UBER_SZ ((off_t)(LOG_WRAPPER_SZ + LOG_UBER_LEN)) #define LOG_NOPEEK 0 #define LOG_DOPEEK 1