File Update-overflow-macro.patch of Package hdf5.34857

From: Egbert Eich <eich@suse.com>
Date: Thu May 23 10:59:41 2024 +0200
Subject: Update overflow macro
Patch-mainline: Upstream
Git-repo: https://github.com/HDFGroup/hdf5
Git-commit: 07744d3c229fcbae6d95626eb0c831fd175c6575
References: bsc#1224158


Signed-off-by: Egbert Eich <eich@suse.de>
---
 src/H5private.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/H5private.h b/src/H5private.h
index 2b7066f067..19d1b93b78 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -383,7 +383,10 @@
 /* Check if a read of size bytes starting at ptr would overflow past
  * the last valid byte, pointed to by buffer_end.
  */
-#define H5_IS_BUFFER_OVERFLOW(ptr, size, buffer_end) (((ptr) + (size)-1) > (buffer_end))
+#define H5_IS_BUFFER_OVERFLOW(ptr, size, buffer_end)                                                         \
+    (((ptr) > (buffer_end)) ||                             /* Bad precondition */                            \
+     ((ptrdiff_t)(size) > (((buffer_end) - (ptr)) + 1)) || /* Typical overflow */                            \
+     ((intptr_t)(size) < 0))                               /* Negative 'size' would wrap 'ptr' */
 
 /* Variant of H5_IS_BUFFER_OVERFLOW, used with functions such as H5Tdecode()
  * that don't take a size parameter, where we need to skip the bounds checks.
openSUSE Build Service is sponsored by