]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Fix three problems with pcre for portability;
authorWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 17 Mar 2005 17:50:29 +0000 (17:50 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 17 Mar 2005 17:50:29 +0000 (17:50 +0000)
  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

srclib/pcre/pcre.c
srclib/pcre/study.c

index a411d00c357f6b176bf9f2f0ddd37586b176f9d7..dc013faf021014d9b70f76ae41597067a7764202 100644 (file)
@@ -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;
index d99b8a992ecba23de0f95b4d0fd316fe5953a46c..d67070a4b3f2c287860204273276008aafa1276b 100644 (file)
@@ -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;