From: Willy Tarreau Date: Wed, 24 Apr 2024 13:57:15 +0000 (+0200) Subject: CLEANUP: h1: make use of the multi-byte matching functions X-Git-Tag: v3.0-dev9~65 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e158b7efb7cd59d8683e2d7a3e7326d039d78b3c;p=thirdparty%2Fhaproxy.git CLEANUP: h1: make use of the multi-byte matching functions Instead of leaving the hard-coded non-trivial operations in the H1 parsing code, let's just rely on the new intops functions that do the same and that are less prone to being accidentally touched. It was verified that the resulting code is exactly the same. --- diff --git a/src/h1.c b/src/h1.c index 0a548937a6..e4181493fb 100644 --- a/src/h1.c +++ b/src/h1.c @@ -575,9 +575,7 @@ int h1_headers_to_hdr_list(char *start, const char *stop, #ifdef HA_UNALIGNED_LE /* speedup: skip bytes not between 0x24 and 0x7e inclusive */ while (ptr <= end - sizeof(int)) { - uint x = *(uint *)ptr; - - if (((x - 0x24242424) | (0x7e7e7e7e - x)) & 0x80808080U) + if (is_char4_outside(*(uint *)ptr, 0x24, 0x7e)) break; ptr += sizeof(int); @@ -927,14 +925,14 @@ int h1_headers_to_hdr_list(char *start, const char *stop, */ #ifdef HA_UNALIGNED_LE64 while (ptr <= end - sizeof(long)) { - if ((*(long *)ptr - 0x0e0e0e0e0e0e0e0eULL) & 0x8080808080808080ULL) + if (is_char8_below_opt(*(ulong *)ptr, 0x0e)) goto http_msg_hdr_val2; ptr += sizeof(long); } #endif #ifdef HA_UNALIGNED_LE while (ptr <= end - sizeof(int)) { - if ((*(int*)ptr - 0x0e0e0e0e) & 0x80808080) + if (is_char4_below_opt(*(uint *)ptr, 0x0e)) goto http_msg_hdr_val2; ptr += sizeof(int); }