[PATCH 5/6] zlib: Misc unrelated updates

Christophe Leroy christophe.leroy at csgroup.eu
Tue Jul 9 12:31:17 CEST 2024


From: Michal Simek <michal.simek at amd.com>

This patch adds misc updates to better match zlib original code.

It is split out of a previous version of
patch ("zlib: Port fix for CVE-2016-9841 to U-Boot)
as those changes were unrelated.

Signed-off-by: Michal Simek <michal.simek at amd.com>
[chleroy: Split out of patch ("zlib: Port fix for CVE-2016-9841 to U-Boot)]
Signed-off-by: Christophe Leroy <christophe.leroy at csgroup.eu>
---
 lib/zlib/inffast.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lib/zlib/inffast.c b/lib/zlib/inffast.c
index 19236f1e23..b5a0adcce6 100644
--- a/lib/zlib/inffast.c
+++ b/lib/zlib/inffast.c
@@ -1,5 +1,5 @@
 /* inffast.c -- fast decoding
- * Copyright (C) 1995-2004 Mark Adler
+ * Copyright (C) 1995-2008, 2010, 2013 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -47,12 +47,13 @@
       requires strm->avail_out >= 258 for each loop to avoid checking for
       output space.
  */
-void inflate_fast(z_streamp strm, unsigned start)
-/* start: inflate()'s starting value for strm->avail_out */
+void ZLIB_INTERNAL inflate_fast(strm, start)
+z_streamp strm;
+unsigned start;         /* inflate()'s starting value for strm->avail_out */
 {
     struct inflate_state FAR *state;
-    unsigned char FAR *in;      /* local strm->next_in */
-    unsigned char FAR *last;    /* while in < last, enough input available */
+    z_const unsigned char FAR *in;      /* local strm->next_in */
+    z_const unsigned char FAR *last;    /* have enough input while in < last */
     unsigned char FAR *out;     /* local strm->next_out */
     unsigned char FAR *beg;     /* inflate()'s initial strm->next_out */
     unsigned char FAR *end;     /* while out < end, enough space available */
@@ -177,7 +178,8 @@ void inflate_fast(z_streamp strm, unsigned start)
                 if (dist > op) {                /* see if copy from window */
                     op = dist - op;             /* distance back in window */
                     if (op > whave) {
-                        strm->msg = (char *)"invalid distance too far back";
+                        strm->msg =
+                            (char *)"invalid distance too far back";
                         state->mode = BAD;
                         break;
                     }
-- 
2.44.0



More information about the U-Boot mailing list