Skip to content

Commit

Permalink
Fix rare UB on left-shift signed int overflow
Browse files Browse the repository at this point in the history
By default, most commonly used compilers *define* some behaviour when
this overflow occurs, such that the program will continue normally,
without any negative consequences.

Severity: Minor
Fixes OSS-Fuzz#40201
  • Loading branch information
liviuchircu committed Oct 2, 2022
1 parent eb8f8b8 commit 2ba963b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions parser/parse_hname2.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
#include "keys.h"
#include "../ut.h" /* q_memchr */

#define LOWER_BYTE(b) ((b) | 0x20)
#define LOWER_DWORD(d) ((d) | 0x20202020)
#define LOWER_BYTE(b) ((b) | 0x20U)
#define LOWER_DWORD(d) ((d) | 0x20202020U)

/*
* Skip all white-chars and return position of the first
Expand Down Expand Up @@ -102,10 +102,10 @@ static inline char* skip_ws(char* p, char *end)
* (Sparc for example)
*/
#define READ(addr) \
(*((unsigned char *)addr + 0) + \
(*((unsigned char *)addr + 1) << 8) + \
(*((unsigned char *)addr + 2) << 16) + \
(*((unsigned char *)addr + 3) << 24))
((unsigned)*((unsigned char *)addr + 0) + \
((unsigned)*((unsigned char *)addr + 1) << 8) + \
((unsigned)*((unsigned char *)addr + 2) << 16) + \
((unsigned)*((unsigned char *)addr + 3) << 24))

#ifdef FUZZ_BUILD
/* fuzzers are sensible to heap read overflows, so enable all "HAVE" checks */
Expand Down

0 comments on commit 2ba963b

Please sign in to comment.