summaryrefslogtreecommitdiff
path: root/srclib
diff options
context:
space:
mode:
authorWilliam A. Rowe Jr <wrowe@apache.org>2005-03-17 17:50:29 +0000
committerWilliam A. Rowe Jr <wrowe@apache.org>2005-03-17 17:50:29 +0000
commitb1d6541d7c96baaff40b16882350ababca358284 (patch)
tree78237b6fe318452905c599d98fc79a184bb5b930 /srclib
parentcdea6cc2b9eee9905d684d09581e62455bda0f49 (diff)
downloadhttpd-b1d6541d7c96baaff40b16882350ababca358284.tar.gz
Fix three problems with pcre for portability;
1. study.c's pointer arg didn't jive with pcre_fullinfo()'s prototype, however there was no (trivial) way to get them to concur. Cast in this case was the least of several evils. 2. byteflip had an error for high-bit set bytes, because right shift signed is allowed to extend the sign bit. These had to be unsigned, and the real_pcre types were the safest way to do this. 3. split byteflip into byteflip2/4, to drop size truncation emits, as the arguments are unambigiously 16 or 32 bits as defined in pcre_internal.h. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@157948 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'srclib')
-rw-r--r--srclib/pcre/pcre.c40
-rw-r--r--srclib/pcre/study.c2
2 files changed, 22 insertions, 20 deletions
diff --git a/srclib/pcre/pcre.c b/srclib/pcre/pcre.c
index a411d00c35..dc013faf02 100644
--- a/srclib/pcre/pcre.c
+++ b/srclib/pcre/pcre.c
@@ -577,18 +577,22 @@ Arguments:
Returns: the flipped value
*/
-static long int
-byteflip(long int value, int n)
+static pcre_uint16
+byteflip2(pcre_uint16 value)
+{
+return ((value & 0x00ff) << 8) |
+ ((value & 0xff00) >> 8);
+}
+
+static pcre_uint32
+byteflip4(pcre_uint32 value)
{
-if (n == 2) return ((value & 0x00ff) << 8) | ((value & 0xff00) >> 8);
return ((value & 0x000000ff) << 24) |
((value & 0x0000ff00) << 8) |
((value & 0x00ff0000) >> 8) |
((value & 0xff000000) >> 24);
}
-
-
/*************************************************
* Test for a byte-flipped compiled regex *
*************************************************/
@@ -613,27 +617,25 @@ static real_pcre *
try_flipped(const real_pcre *re, real_pcre *internal_re,
const pcre_study_data *study, pcre_study_data *internal_study)
{
-if (byteflip(re->magic_number, sizeof(re->magic_number)) != MAGIC_NUMBER)
+if (byteflip4(re->magic_number) != MAGIC_NUMBER)
return NULL;
*internal_re = *re; /* To copy other fields */
-internal_re->size = byteflip(re->size, sizeof(re->size));
-internal_re->options = byteflip(re->options, sizeof(re->options));
-internal_re->top_bracket = byteflip(re->top_bracket, sizeof(re->top_bracket));
-internal_re->top_backref = byteflip(re->top_backref, sizeof(re->top_backref));
-internal_re->first_byte = byteflip(re->first_byte, sizeof(re->first_byte));
-internal_re->req_byte = byteflip(re->req_byte, sizeof(re->req_byte));
-internal_re->name_table_offset = byteflip(re->name_table_offset,
- sizeof(re->name_table_offset));
-internal_re->name_entry_size = byteflip(re->name_entry_size,
- sizeof(re->name_entry_size));
-internal_re->name_count = byteflip(re->name_count, sizeof(re->name_count));
+internal_re->size = byteflip4(re->size);
+internal_re->options = byteflip4(re->options);
+internal_re->top_bracket = byteflip2(re->top_bracket);
+internal_re->top_backref = byteflip2(re->top_backref);
+internal_re->first_byte = byteflip2(re->first_byte);
+internal_re->req_byte = byteflip2(re->req_byte);
+internal_re->name_table_offset = byteflip2(re->name_table_offset);
+internal_re->name_entry_size = byteflip2(re->name_entry_size);
+internal_re->name_count = byteflip2(re->name_count);
if (study != NULL)
{
*internal_study = *study; /* To copy other fields */
- internal_study->size = byteflip(study->size, sizeof(study->size));
- internal_study->options = byteflip(study->options, sizeof(study->options));
+ internal_study->size = byteflip4(study->size);
+ internal_study->options = byteflip4(study->options);
}
return internal_re;
diff --git a/srclib/pcre/study.c b/srclib/pcre/study.c
index d99b8a992e..d67070a4b3 100644
--- a/srclib/pcre/study.c
+++ b/srclib/pcre/study.c
@@ -441,7 +441,7 @@ if ((re->options & (PCRE_ANCHORED|PCRE_FIRSTSET|PCRE_STARTLINE)) != 0)
tables = re->tables;
if (tables == NULL)
- (void)pcre_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES, &tables);
+ (void)pcre_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES, (void*)&tables);
compile_block.lcc = tables + lcc_offset;
compile_block.fcc = tables + fcc_offset;