-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Stefan de Konink schreef:
> On Wed, 26 Sep 2007, Alvaro Lopez Ortega wrote:
>
>> Stefan de Konink wrote, On 26/09/07 13:18:
>>
>> > This is because the cmp_str macro in header.c uses the sizeof keyword.
>> > sizeof is able to return the length of a hard-coded array, but not after
>> > the addres of this array has been cast. Example:
>> >
>> > int main() {
>> > printf("%i\n", sizeof("test test"));
>> > printf("%i\n", sizeof((const char *)"test test"));
>> > }
>>
>> Great catch!!
>> I have just committed r923 with your patch.
>>
>> Thanks Stefan :-)
>
>
> I'll forward the compliment ;) Btw, will you fix the mailinglist?
After evaluating my work, I found out that it *DOES NOT SOLVE IT*
(str" ") will just work... but adding the +1 (so making the variable a
pointer!) still brings back the issues.
Now what I can think of:
- - Remove the first character from the code. "GET" -> "ET or solve it
with a define with the readable name GET, but "ET" defined. Since strlen
is not an option I guess. [Checked and works]
- - Make an intermediate macro specifically for this function which solves
the issue, hence first recover the length (minus one) and then increase
the pointer. So essentially wrap an macro around the strncmp again where
the sizeof can be set by the caller and for this function we should put
there sizeof - 1. (My preference would be to just put the strncmp in the
detect macro then there is access to all literals)
#define detect_method(l,str,mthd) \
if (strncmp(line+1, (str" ")+1, sizeof(str)-1) == 0) { \
hdr->method = http_ ## mthd; \
*pointer += sizeof(str); \
return ret_ok; \
}
[Checked and works]
- - Check the first character anyway... (hence removing the +1)
Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFG+vv7YH1+F2Rqwn0RCsAcAKCLzj3r0Im5crAuZCM1ZxIgPvUcqgCdEWKD
ZrhM2AmG2/CIA2XzjTx2Ojo=
=e25E
-----END PGP SIGNATURE-----
_______________________________________________
Cherokee mailing list
[email protected]
http://cherokee-project.com/cgi-bin/mailman/listinfo/cherokee