From 6fd7d51025084fd2a157a0dbf433b411cd449389 Mon Sep 17 00:00:00 2001
From: Even Rouault <[EMAIL REDACTED]>
Date: Thu, 16 May 2024 18:49:21 +0200
Subject: [PATCH] tiffset.c: avoid false positive Coverity Scan warning on
64-bit builds (CID 1518997)
---
tools/tiffset.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tools/tiffset.c b/tools/tiffset.c
index c768d989..c21acf7c 100644
--- a/tools/tiffset.c
+++ b/tools/tiffset.c
@@ -461,9 +461,11 @@ int main(int argc, char *argv[])
fsize = TIFFftell(fp) + 1;
rewind(fp);
- if (fsize >
- TIFF_TMSIZE_T_MAX || /* for x32 tmsize_t is only int32_t */
- fsize <= 0)
+ /* for x32 tmsize_t is only int32_t. The - 1 is just here to make
+ * Coverity Scan happy on 64 bit builds where the condition would
+ * be always true otherwise.
+ */
+ if (fsize > TIFF_TMSIZE_T_MAX - 1 || fsize <= 0)
{
fprintf(
stderr,