Skip to content

Commit

Permalink
Improve previous commit
Browse files Browse the repository at this point in the history
* fix 2 regressions
* optimize (merge) some HAVE() checks
  • Loading branch information
liviuchircu committed Mar 28, 2022
1 parent 7312678 commit 85d7691
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions parser/case_call.h
Expand Up @@ -31,8 +31,6 @@


#define ID_INF_CASE \
if (!HAVE(4)) \
goto other; \
switch(LOWER_DWORD(val)) { \
case __id1_: \
hdr->type = HDR_CALLID_T; \
Expand All @@ -59,6 +57,8 @@

#define call_CASE \
p += 4; \
if (!HAVE(4)) \
goto other; \
val = READ(p); \
ID_INF_CASE; \
goto other;
Expand Down
4 changes: 1 addition & 3 deletions parser/case_cont.h
Expand Up @@ -67,8 +67,6 @@
switch(LOWER_DWORD(val)) { \
case _osit_: \
p += 4; \
if (!HAVE(4)) \
goto other; \
val = READ(p); \
ion_CASE; \
goto other; \
Expand All @@ -91,7 +89,7 @@
goto dc_cont; \
case _disp_: \
p += 4; \
if (!HAVE(4)) \
if (!HAVE(8)) \
goto other; \
val = READ(p); \
DISPOSITION_CASE; \
Expand Down
4 changes: 1 addition & 3 deletions parser/case_max.h
Expand Up @@ -38,8 +38,6 @@
switch(LOWER_DWORD(val)) { \
case _forw_: \
p += 4; \
if (!HAVE(4)) \
goto other; \
val = READ(p); \
ARDS_CASE; \
goto other; \
Expand All @@ -48,7 +46,7 @@

#define max_CASE \
p += 4; \
if (!HAVE(4)) \
if (!HAVE(8)) \
goto other; \
val = READ(p); \
FORW_CASE; \
Expand Down
4 changes: 1 addition & 3 deletions parser/case_reco.h
Expand Up @@ -38,8 +38,6 @@
switch(LOWER_DWORD(val)) { \
case _rd_r_: \
p += 4; \
if (!HAVE(4)) \
goto other; \
val = READ(p); \
OUTE_CASE; \
goto other; \
Expand All @@ -48,7 +46,7 @@

#define reco_CASE \
p += 4; \
if (!HAVE(4)) \
if (!HAVE(8)) \
goto other; \
val = READ(p); \
RD_R_CASE; \
Expand Down
2 changes: 1 addition & 1 deletion parser/parse_hname2.c
Expand Up @@ -109,7 +109,7 @@ static inline char* skip_ws(char* p, char *end)

#ifdef FUZZ_BUILD
/* fuzzers are sensible to heap read overflows, so enable all "HAVE" checks */
#define HAVE(bytes) (end - p < (bytes))
#define HAVE(bytes) (end - p >= (long)(bytes))
#else
/* with PKG memory, parser read overflows of a few bytes are harmless, since
* the memory is pre-allocated and the read cannot SIGSEGV, making the parser
Expand Down

0 comments on commit 85d7691

Please sign in to comment.