Bug 32985 - strange variable truncation with SSI regexes and HTTP_COOKIE
Summary: strange variable truncation with SSI regexes and HTTP_COOKIE
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_include (show other bugs)
Version: 2.0.52
Hardware: PC Linux
: P2 major (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL: http://nodivisions.com/test.shtml
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-07 09:59 UTC by Anthony DiSante
Modified: 2005-01-24 09:24 UTC (History)
1 user (show)



Attachments
proposed fix (484 bytes, patch)
2005-01-14 17:18 UTC, Joe Orton
Details | Diff
variable truncation fix #2 (606 bytes, patch)
2005-01-16 21:34 UTC, Joe Orton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anthony DiSante 2005-01-07 09:59:23 UTC
For certain lengths of HTTP_COOKIE, it seems that SSI regexes (in "expr="
statements) fail to capture the full length of the HTTP_COOKIE variable when
using capturing parentheses.  Here's an example, tested on 2.0.52 on two
different Linux servers:


<!--#set var="HTTP_COOKIE"
value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=n"
-->

Your HTTP_COOKIE is:

"<!--#echo var="HTTP_COOKIE" -->"

<!--#if expr="$HTTP_COOKIE = /(.+)/" -->
...but captured from a regex using (.+), it's truncated to this:

"<!--#echo var="1" -->"
<!--#endif -->


In case this form/webpage messes with that code, just visit this URL:

http://nodivisions.com/test.shtml

Note that the actual value of HTTP_COOKIE doesn't matter; I found this bug while
using 3 real cookie values in it, but then replaced them with all Xes to test. 
Only the length seems to matter.
Comment 1 Joe Orton 2005-01-14 17:18:17 UTC
Created attachment 13999 [details]
proposed fix

There's an off-by-one in the handling of variables which expand to 128
characters, this is a fix, not sure if it's the *correct* fix...
Comment 2 Joe Orton 2005-01-16 21:34:27 UTC
Created attachment 14025 [details]
variable truncation fix #2

fix for variable truncation issue (now with comment)
Comment 3 Joe Orton 2005-01-24 14:40:00 UTC
Fix committed for 2.0.53; thanks for the simple repro case!
Comment 4 Anthony DiSante 2005-01-24 18:24:38 UTC
You're welcome; glad to help.  Thanks for the fix!