You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by wr...@apache.org on 2005/03/17 18:50:31 UTC
svn commit: r157948 - in httpd/httpd/trunk/srclib/pcre: pcre.c study.c
Author: wrowe
Date: Thu Mar 17 09:50:29 2005
New Revision: 157948
URL: http://svn.apache.org/viewcvs?view=rev&rev=157948
Log:
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.
Modified:
httpd/httpd/trunk/srclib/pcre/pcre.c
httpd/httpd/trunk/srclib/pcre/study.c
Modified: httpd/httpd/trunk/srclib/pcre/pcre.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/srclib/pcre/pcre.c?view=diff&r1=157947&r2=157948
==============================================================================
--- httpd/httpd/trunk/srclib/pcre/pcre.c (original)
+++ httpd/httpd/trunk/srclib/pcre/pcre.c Thu Mar 17 09:50:29 2005
@@ -577,18 +577,22 @@
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 @@
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;
Modified: httpd/httpd/trunk/srclib/pcre/study.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/srclib/pcre/study.c?view=diff&r1=157947&r2=157948
==============================================================================
--- httpd/httpd/trunk/srclib/pcre/study.c (original)
+++ httpd/httpd/trunk/srclib/pcre/study.c Thu Mar 17 09:50:29 2005
@@ -441,7 +441,7 @@
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;
Re: svn commit: r157948 - in httpd/httpd/trunk/srclib/pcre: pcre.c study.c
Posted by Joe Orton <jo...@redhat.com>.
On Thu, Mar 17, 2005 at 05:50:31PM -0000, William Rowe wrote:
> Author: wrowe
> Date: Thu Mar 17 09:50:29 2005
> New Revision: 157948
>
> URL: http://svn.apache.org/viewcvs?view=rev&rev=157948
> Log:
>
> 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.
I don't see why this is needed - the last argument to pcre_fullinfo() is
void * already, so the cast is surely unnecessary?
> 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.
Did you send these upstream to Phil Hazel? <ph10 cam.ac.uk>
Regards,
joe