From: Fabian Keil <fk@fabiankeil.de>
Date: Fri, 5 Feb 2021 12:27:13 +0000 (+0100)
Subject: decompress_iob(): Cast value to unsigned char before shifting
X-Git-Tag: v_3_0_32~30
X-Git-Url: http://www.privoxy.org/gitweb/@default-cgi@/static/developer-manual/@default-cgi@show-status?a=commitdiff_plain;h=9788f97d68076acffc11da82a9c65f06cd661b15;p=privoxy.git

decompress_iob(): Cast value to unsigned char before shifting

Prevents a left-shift of a negative value which is undefined behavior.

Reported by: Joshua Rogers (Opera)
---

diff --git a/parsers.c b/parsers.c
index 35e2c330..f905c92a 100644
--- a/parsers.c
+++ b/parsers.c
@@ -609,7 +609,7 @@ jb_err decompress_iob(struct client_state *csp)
              */
             int skip_bytes;
             skip_bytes = *cur++;
-            skip_bytes += *cur++ << 8;
+            skip_bytes += (unsigned char)*cur++ << 8;
 
             /*
              * The number of bytes to skip should be positive