libtiff: Use UINT_MAX

From 2c1d4b6b01102fb8733bad6d00af5a8c21aa8e45 Mon Sep 17 00:00:00 2001
From: Even Rouault <[EMAIL REDACTED]>
Date: Tue, 13 Dec 2022 13:14:30 +0100
Subject: [PATCH] Use UINT_MAX

---
 libtiff/tif_dir.c     | 7 ++++---
 libtiff/tif_dirread.c | 5 +++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/libtiff/tif_dir.c b/libtiff/tif_dir.c
index 3c3cb340..97fb5eb9 100644
--- a/libtiff/tif_dir.c
+++ b/libtiff/tif_dir.c
@@ -30,6 +30,7 @@
  */
 #include "tiffiop.h"
 #include <float.h> /*--: for Rational2Double */
+#include <limits.h>
 
 /*
  * These are used in the backwards compatibility code...
@@ -2070,7 +2071,7 @@ int TIFFSetSubDirectory(TIFF *tif, uint64_t diroff)
     if (diroff == 0)
     {
         /* Special case to invalidate the tif_lastdiroff member. */
-        tif->tif_curdir = 0xffffffffu;
+        tif->tif_curdir = UINT_MAX;
     }
     else
     {
@@ -2080,7 +2081,7 @@ int TIFFSetSubDirectory(TIFF *tif, uint64_t diroff)
             probablySubIFD = 1;
         }
         /* -1 because TIFFReadDirectory() will increment tif_curdir. */
-        tif->tif_curdir = curdir == 0 ? 0xffffffffu : curdir - 1;
+        tif->tif_curdir = curdir == 0 ? UINT_MAX : curdir - 1;
     }
 
     tif->tif_nextdiroff = diroff;
@@ -2089,7 +2090,7 @@ int TIFFSetSubDirectory(TIFF *tif, uint64_t diroff)
      * back. */
     if (!retval)
     {
-        if (tif->tif_curdir == 0xffffffffu)
+        if (tif->tif_curdir == UINT_MAX)
             tif->tif_curdir = 0;
         else
             tif->tif_curdir++;
diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c
index 799dbc5a..fc21851b 100644
--- a/libtiff/tif_dirread.c
+++ b/libtiff/tif_dirread.c
@@ -37,6 +37,7 @@
 #include "tiffconf.h"
 #include "tiffiop.h"
 #include <float.h>
+#include <limits.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -4076,7 +4077,7 @@ int TIFFReadDirectory(TIFF *tif)
      * reading of the directory. Otherwise, invalid IFD offsets could corrupt
      * the IFD list. */
     if (!_TIFFCheckDirNumberAndOffset(
-            tif, tif->tif_curdir == 0xFFFFFFFFU ? 0 : tif->tif_curdir + 1,
+            tif, tif->tif_curdir == UINT_MAX ? 0 : tif->tif_curdir + 1,
             nextdiroff))
     {
         return 0; /* bad offset (IFD looping or more than TIFF_MAX_DIR_COUNT
@@ -4093,7 +4094,7 @@ int TIFFReadDirectory(TIFF *tif)
     /* Set global values after a valid directory has been fetched.
      * tif_diroff is already set to nextdiroff in TIFFFetchDirectory() in the
      * beginning. */
-    if (tif->tif_curdir == 0xffffffffu)
+    if (tif->tif_curdir == UINT_MAX)
         tif->tif_curdir = 0;
     else
         tif->tif_curdir++;