Skip to content

Commit 81fe3d9

Browse files
committed
Merge pull request #44 with tweaks
Fix theoretical SEGV concern (Workaround 5.0 asan findings)
2 parents 8918123 + cc4df34 commit 81fe3d9

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

picohttpparser.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@
7171
#define ADVANCE_TOKEN(tok, toklen) \
7272
do { \
7373
const char *tok_start = buf; \
74-
static const char ALIGNED(16) ranges2[] = "\000\040\177\177"; \
74+
static const char ALIGNED(16) ranges2[16] = "\000\040\177\177"; \
7575
int found2; \
76-
buf = findchar_fast(buf, buf_end, ranges2, sizeof(ranges2) - 1, &found2); \
76+
buf = findchar_fast(buf, buf_end, ranges2, 4, &found2); \
7777
if (!found2) { \
7878
CHECK_EOF(); \
7979
} \
@@ -136,15 +136,11 @@ static const char *get_token_to_eol(const char *buf, const char *buf_end, const
136136
const char *token_start = buf;
137137

138138
#ifdef __SSE4_2__
139-
static const char ranges1[] = "\0\010"
140-
/* allow HT */
141-
"\012\037"
142-
/* allow SP and up to but not including DEL */
143-
"\177\177"
144-
/* allow chars w. MSB set */
145-
;
139+
static const char ALIGNED(16) ranges1[16] = "\0\010" /* allow HT */
140+
"\012\037" /* allow SP and up to but not including DEL */
141+
"\177\177"; /* allow chars w. MSB set */
146142
int found;
147-
buf = findchar_fast(buf, buf_end, ranges1, sizeof(ranges1) - 1, &found);
143+
buf = findchar_fast(buf, buf_end, ranges1, 6, &found);
148144
if (found)
149145
goto FOUND_CTL;
150146
#else

0 commit comments

Comments
 (0)