Skip to content

Commit

Permalink
Merge pull request #44 with tweaks
Browse files Browse the repository at this point in the history
Fix theoretical SEGV concern (Workaround 5.0 asan findings)
  • Loading branch information
kazuho committed May 17, 2019
2 parents 8918123 + cc4df34 commit 81fe3d9
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions picohttpparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@
#define ADVANCE_TOKEN(tok, toklen) \
do { \
const char *tok_start = buf; \
static const char ALIGNED(16) ranges2[] = "\000\040\177\177"; \
static const char ALIGNED(16) ranges2[16] = "\000\040\177\177"; \
int found2; \
buf = findchar_fast(buf, buf_end, ranges2, sizeof(ranges2) - 1, &found2); \
buf = findchar_fast(buf, buf_end, ranges2, 4, &found2); \
if (!found2) { \
CHECK_EOF(); \
} \
Expand Down Expand Up @@ -136,15 +136,11 @@ static const char *get_token_to_eol(const char *buf, const char *buf_end, const
const char *token_start = buf;

#ifdef __SSE4_2__
static const char ranges1[] = "\0\010"
/* allow HT */
"\012\037"
/* allow SP and up to but not including DEL */
"\177\177"
/* allow chars w. MSB set */
;
static const char ALIGNED(16) ranges1[16] = "\0\010" /* allow HT */
"\012\037" /* allow SP and up to but not including DEL */
"\177\177"; /* allow chars w. MSB set */
int found;
buf = findchar_fast(buf, buf_end, ranges1, sizeof(ranges1) - 1, &found);
buf = findchar_fast(buf, buf_end, ranges1, 6, &found);
if (found)
goto FOUND_CTL;
#else
Expand Down

0 comments on commit 81fe3d9

Please sign in to comment.