decompress_iob(): Cast value to unsigned char before shifting
authorFabian Keil <fk@fabiankeil.de>
Fri, 5 Feb 2021 12:27:13 +0000 (13:27 +0100)
committerFabian Keil <fk@fabiankeil.de>
Sun, 21 Feb 2021 16:30:16 +0000 (17:30 +0100)
Prevents a left-shift of a negative value which is undefined behavior.

Reported by: Joshua Rogers (Opera)

parsers.c

index 35e2c33..f905c92 100644 (file)
--- 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