From: Yann Ylavic Date: Thu, 28 Mar 2019 16:24:30 +0000 (+0000) Subject: Provide TEST_CHAR marco in test_char.h X-Git-Tag: 2.5.0-alpha2-ci-test-only~2087 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5528a9b36f127a11cd442aeac91de9f92ce87e4b;p=thirdparty%2Fapache%2Fhttpd.git Provide TEST_CHAR marco in test_char.h For (internal) usage outside server/util.c, mod_log_forensic for now and mod_cache (T_HTTP_TOKEN_STOP) in a few... git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1856490 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/loggers/mod_log_forensic.c b/modules/loggers/mod_log_forensic.c index 359cd63935e..f4ef129a570 100644 --- a/modules/loggers/mod_log_forensic.c +++ b/modules/loggers/mod_log_forensic.c @@ -123,7 +123,7 @@ static char *log_escape(char *q, const char *e, const char *p) { for ( ; *p ; ++p) { ap_assert(q < e); - if (test_char_table[*(unsigned char *)p]&T_ESCAPE_FORENSIC) { + if (TEST_CHAR(*p, T_ESCAPE_FORENSIC)) { ap_assert(q+2 < e); *q++ = '%'; ap_bin2hex(p, 1, q); diff --git a/server/gen_test_char.c b/server/gen_test_char.c index 48ae6f47d02..cd20577e6aa 100644 --- a/server/gen_test_char.c +++ b/server/gen_test_char.c @@ -167,7 +167,16 @@ int main(int argc, char *argv[]) printf("0x%03x%c", flags, (c < 255) ? ',' : ' '); } - printf("\n};\n"); + printf("\n};\n\n"); + + printf( + "/* we assume the folks using this ensure 0 <= c < 256... which means\n" + " * you need a cast to (unsigned char) first, you can't just plug a\n" + " * char in here and get it to work, because if char is signed then it\n" + " * will first be sign extended.\n" + " */\n" + "#define TEST_CHAR(c, f) (test_char_table[(unsigned char)(c)] & (f))\n" + ); return 0; } diff --git a/server/util.c b/server/util.c index a4e42656678..3e1b536de7e 100644 --- a/server/util.c +++ b/server/util.c @@ -76,13 +76,6 @@ */ #include "test_char.h" -/* we assume the folks using this ensure 0 <= c < 256... which means - * you need a cast to (unsigned char) first, you can't just plug a - * char in here and get it to work, because if char is signed then it - * will first be sign extended. - */ -#define TEST_CHAR(c, f) (test_char_table[(unsigned char)(c)] & (f)) - /* Win32/NetWare/OS2 need to check for both forward and back slashes * in ap_getparents() and ap_escape_url. */