344 Commits

Author SHA1 Message Date
dfa5c28120 Use %pm in order to save 8k of stack in 'ap_pcfg_strerror'
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1563379 13f79535-47bb-0310-9956-ffa450edef68
2014-02-01 07:55:58 +00:00
111f35f4e1 Be more clever when allocating memory for log item to be escaped.
This should be faster and save about 70-100 bytes in the request pool with the default config.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1485409 13f79535-47bb-0310-9956-ffa450edef68
2013-05-22 20:38:35 +00:00
7af3897b16 Revert change in order to apply a better solution.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1485379 13f79535-47bb-0310-9956-ffa450edef68
2013-05-22 19:45:23 +00:00
9bc9d79079 core: Stop the HTTP_IN filter from attempting to write error buckets
to the output filters, which is bogus in the proxy case. Create a
clean mapping from APR codes to HTTP status codes, and use it where
needed.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1482522 13f79535-47bb-0310-9956-ffa450edef68
2013-05-14 18:58:06 +00:00
997e0f6d33 core: Add the ability to do explicit matching on weak and strong ETags
as per RFC2616 Section 13.3.3.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1479528 13f79535-47bb-0310-9956-ffa450edef68
2013-05-06 11:41:10 +00:00
4ffceed48e Turn a int into a apr_size_t for a variabe used to compute a string length
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1468089 13f79535-47bb-0310-9956-ffa450edef68
2013-04-15 14:17:39 +00:00
8c101dfe70 Part two of r1467523
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1467792 13f79535-47bb-0310-9956-ffa450edef68
2013-04-14 15:47:53 +00:00
ee3815bda9 Static var not neccessary here
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1467523 13f79535-47bb-0310-9956-ffa450edef68
2013-04-13 00:07:44 +00:00
86087766c6 Be more clever when allocating memory for log item to be escaped.
This should save about 70-100 bytes in the request pool with the default config.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1461869 13f79535-47bb-0310-9956-ffa450edef68
2013-03-27 21:57:44 +00:00
bb69ec6cfe Remove useless tests.
Turn
   if (*x && apr_isspace(*x))
into
   if (apr_isspace(*x))

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1452128 13f79535-47bb-0310-9956-ffa450edef68
2013-03-03 21:25:46 +00:00
3f42fb8b49 Can't figure out why we allocate len+2 bytes here. Len+1 should be enough.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1442759 13f79535-47bb-0310-9956-ffa450edef68
2013-02-05 21:32:51 +00:00
023e47cb2f Add helper function to execute command w args and get one line of output. Allow AuthLDAPBindPassword to have exec: argument like SSLPassPhraseDialog
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1433478 13f79535-47bb-0310-9956-ffa450edef68
2013-01-15 16:00:44 +00:00
40431c8d75 Add some caching for password hash validation.
Password hash functions must be expensive in order to be secure. But
if they have to be re-evaluated for every request, performance
suffers.

As a minimal remedy, cache the most recent result for every
connection. This gives a great performance boost if a web browser
does many requests on the same connection with the same
user+password.  In principle, this may keep the plain text password
around longer than before. But in practice, there won't be much
difference since user+password can already remain in some unused
data bucket for longer than the request duration.

A proper solution still needs to be found for connections from
proxies which may carry requests for many different users.

While it currently only requires the conn_rec, the new
ap_password_validate() function takes username and request_rec to
allow future extensions, like detection of brute-force attempts.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1427548 13f79535-47bb-0310-9956-ffa450edef68
2013-01-01 20:16:30 +00:00
f726113d33 Add an option to enforce stricter HTTP conformance
This is a first stab, the checks will likely have to be revised.
For now, we check

 * if the request line contains control characters
 * if the request uri has fragment or username/password
 * that the request method is standard or registered with RegisterHttpMethod
 * that the request protocol is of the form HTTP/[1-9]+.[0-9]+,
   or missing for 0.9
 * if there is garbage in the request line after the protocol
 * if any request header contains control characters
 * if any request header has an empty name
 * for the host name in the URL or Host header:
   - if an IPv4 dotted decimal address: Reject octal or hex values, require
     exactly four parts
   - if a DNS host name: Reject non-alphanumeric characters besides '.' and
     '-'. As a side effect, this rejects multiple Host headers.
 * if any response header contains control characters
 * if any response header has an empty name
 * that the Location response header (if present) has a valid scheme and is
   absolute

If we have a host name both from the URL and the Host header, we replace the
Host header with the value from the URL to enforce RFC conformance.

There is a log-only mode, but the loglevels of the logged messages need some
thought/work. Currently, the  checks for incoming data log for 'core' and the
checks for outgoing data log for 'http'. Maybe we need a way to configure the
loglevels separately from the core/http loglevels.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1426877 13f79535-47bb-0310-9956-ffa450edef68
2012-12-30 01:23:24 +00:00
91c6296f27 remove unnecessary cast
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1422712 13f79535-47bb-0310-9956-ffa450edef68
2012-12-16 23:16:55 +00:00
c39c61637e add new ap_bin2hex() utility function
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1422549 13f79535-47bb-0310-9956-ffa450edef68
2012-12-16 11:49:14 +00:00
af3f141309 follow-up to r1389481: find/use getloadavg() prototype on Solaris
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1397716 13f79535-47bb-0310-9956-ffa450edef68
2012-10-12 20:22:33 +00:00
24ec4aff0e follow up to r1390564: we just need scope, not control structure
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1397710 13f79535-47bb-0310-9956-ffa450edef68
2012-10-12 20:01:46 +00:00
44cb002091 Extract some more data through the server load API:
* include/httpd.h (struct ap_sload_t): Add bytes_served, access_count
  fields.

* server/util.c (ap_get_sload): Fill in those fields.

Submitted by: Jan Kaluza <jkaluza redhat.com>


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1393338 13f79535-47bb-0310-9956-ffa450edef68
2012-10-03 08:20:50 +00:00
ade3b53bb5 wrap var inits in the macro w/ a do-while.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1390564 13f79535-47bb-0310-9956-ffa450edef68
2012-09-26 15:28:27 +00:00
b633191c6d More accurate counts of busy and ready/idle
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1390562 13f79535-47bb-0310-9956-ffa450edef68
2012-09-26 15:24:23 +00:00
1722688cb3 Break out loadavg from Apache load.... one is quick, the other
isn't so much, and so why load things up when wanting just
the server loadavg?

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1389564 13f79535-47bb-0310-9956-ffa450edef68
2012-09-24 20:50:58 +00:00
1b69b60f1d minor name change, but I expect most will just want/need/use
the current load average, so simplify the name

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1389506 13f79535-47bb-0310-9956-ffa450edef68
2012-09-24 18:17:50 +00:00
1134cfb81d Would be nice to have some sort of canonical definition
of server loading for Apache. So create a struct that
holds some useful data. The hope is that for those
platforms that lack getloadavg(), people will write
replacements.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1389481 13f79535-47bb-0310-9956-ffa450edef68
2012-09-24 16:56:58 +00:00
c5c6e82715 make the CT check in ap_parse_form_data case-insensitive
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1372419 13f79535-47bb-0310-9956-ffa450edef68
2012-08-13 13:37:15 +00:00
62bdc76f18 Ditch the !, since that would result in the opposite of what was intended
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1372349 13f79535-47bb-0310-9956-ffa450edef68
2012-08-13 10:03:06 +00:00
568fe20713 core: use a cheaper way of matching the content-type when parsing form data
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1372305 13f79535-47bb-0310-9956-ffa450edef68
2012-08-13 08:07:07 +00:00
bdc02db4a3 core:
Be less strict when checking whether Content-Type is set to "application/x-www-form-urlencoded" 
when parsing POST data, or we risk losing data with an appended charset.

PR 53698
Reported by: Petter Berntsen < sluggr gmail.com >

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1372054 13f79535-47bb-0310-9956-ffa450edef68
2012-08-12 07:45:55 +00:00
0d77ab651b make varbuf functions treat AP_VARBUF_UNKNOWN consistently, improve docs
ap_varbuf_pdup(): copying the whole buffer in case strlen ==
AP_VARBUF_UNKNOWN does not make sense as the caller can not set
the exact buffer size, only a minimum. No API change as previously
the behavior with AP_VARBUF_UNKNOWN was undocumented.

regsub_core(): Checking for vb->buf is useless, it cannot be NULL
unless ap_varbuf_init has not been called.

ap_varbuf_cfg_getline(): Initially, allocate enough memory to hold
an empty line. If strlen == AP_VARBUF_UNKNOWN, use strlen(buf) instead
of undefined behavior.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1359884 13f79535-47bb-0310-9956-ffa450edef68
2012-07-10 20:19:03 +00:00
a1b0be3dcb Make ap_regcomp() return AP_REG_ESPACE if out of memory. Make ap_pregcomp()
abort if out of memory.

This raises the minimum PCRE requirement to version 6.0, released in 2005.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1343109 13f79535-47bb-0310-9956-ffa450edef68
2012-05-27 21:40:00 +00:00
4942a552fd Fix treatment of regex backreferences.
r904765 only made half of the necessary changes to remove the use
of '&' as an alias for '$0' and allow to escape any character with a
backslash.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1307067 13f79535-47bb-0310-9956-ffa450edef68
2012-03-29 19:24:04 +00:00
2aa21a62b1 Clean up size_t abuse, part 2. ap_malloc/calloc/realloc are explicitly
excluded from this cleanup as they must be signature identical to the
clib functions, and although the definition of size_t has been flakey,
the definition of those functions appears to be generally clean since
ANSI C.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1228323 13f79535-47bb-0310-9956-ffa450edef68
2012-01-06 18:15:08 +00:00
91ce790cd3 Limit length of lines in .htaccess to 8K again, to reduce DoS potential.
Make ap_varbuf_cfg_getline() strictly enforce the max_len parameter.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1213338 13f79535-47bb-0310-9956-ffa450edef68
2011-12-12 17:50:33 +00:00
92e366007c Add lots of unique tags to error log messages
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1209766 13f79535-47bb-0310-9956-ffa450edef68
2011-12-02 23:02:04 +00:00
fd962221ea Fix integer overflow in ap_pregsub. This can be triggered e.g.
with mod_setenvif via a malicious .htaccess

CVE-2011-3607
http://www.halfdog.net/Security/2011/ApacheModSetEnvIfIntegerOverflow/


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1198940 13f79535-47bb-0310-9956-ffa450edef68
2011-11-07 21:13:40 +00:00
05eb254d1b No need to zero memory that we will overwrite anyway
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1198934 13f79535-47bb-0310-9956-ffa450edef68
2011-11-07 21:04:40 +00:00
95ced96d65 Remove magic numbers; ensure that an invalid nmatch is corrected
tagged

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1194912 13f79535-47bb-0310-9956-ffa450edef68
2011-10-29 16:07:16 +00:00
b84938b043 mod_include: Add support for application/x-www-form-urlencoded encoding
and decoding.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1194870 13f79535-47bb-0310-9956-ffa450edef68
2011-10-29 11:13:37 +00:00
308d06fd8d Improve handling of maxlen = APR_SIZE_MAX, noticed by Jim.
Use apr_pregsub_ex() and maxlen = 0 for unlimited in mod_substitute.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1189985 13f79535-47bb-0310-9956-ffa450edef68
2011-10-27 20:15:36 +00:00
04ca93ecff Limit ap_pregsub() to 64K, add ap_pregsub_ex() for longer strings and with
better error reporting. Modify ap_varbuf_regsub() to be similar to
ap_pregsub_ex().


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1188950 13f79535-47bb-0310-9956-ffa450edef68
2011-10-25 22:29:13 +00:00
95457d4698 flip operator in comment for r1182887 and add some whitespace
to highlight the restriction on nmatch.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1183007 13f79535-47bb-0310-9956-ffa450edef68
2011-10-13 17:41:41 +00:00
2632a97856 Force the honoring of AP_MAX_REG_MATCH
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1182887 13f79535-47bb-0310-9956-ffa450edef68
2011-10-13 14:49:39 +00:00
caf0908cf5 Shut up gcc/glibc warning about ignoring write()'s return value.
This may actually fix a real bug in case the error log is directed to a FIFO.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1180334 13f79535-47bb-0310-9956-ffa450edef68
2011-10-08 07:54:31 +00:00
e1fc6f9d0c Some varbuf enhancements:
- Introduce new ap_varbuf_pdup() and ap_varbuf_regsub() functions.
- Fix some bugs in ap_varbuf_strmemcat().
- Make ap_varbuf.buf point to an empty string if no buffer has been allocated,
  yet.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1176018 13f79535-47bb-0310-9956-ffa450edef68
2011-09-26 20:05:09 +00:00
427c85bd23 Cleanup effort in prep for GA push:
Trim trailing whitespace... no func change



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1174751 13f79535-47bb-0310-9956-ffa450edef68
2011-09-23 13:39:32 +00:00
01ed21af9d Add wrappers for malloc, calloc, realloc that check for out of memory
situations.  Use them in most places where malloc, and friends are used.
This results in clean error messages in an out of memory situation instead of
segfaulting or silently malfunctioning. In some places, it just allows to
remove some logging code.

PR 51568, PR 51569, PR 51571.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1172686 13f79535-47bb-0310-9956-ffa450edef68
2011-09-19 16:25:42 +00:00
f868cec39b Give a slightly more direct hint when no global ServerName is set. I still
think this buries the lead, but it's hard to rewrite to change the emphasis
yet maintain googleability.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1172410 13f79535-47bb-0310-9956-ffa450edef68
2011-09-19 01:36:39 +00:00
84a104bb22 Add ap_varbuf API for resizable buffers.
Increase length limit of lines in the configuration file to 16MB.
Increase length limit of lines in the group file to 16MB.

PR: 45888, 50824, 43084

Windows and Netware build changes are untested.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1157354 13f79535-47bb-0310-9956-ffa450edef68
2011-08-13 09:06:35 +00:00
51692222f6 Various code cleanup
PR: 51398
Submitted by: Christophe Jaillet <christophe jaillet wanadoo fr>


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1138627 13f79535-47bb-0310-9956-ffa450edef68
2011-06-22 20:45:34 +00:00
255f723fef We already have ap_str_tolower(), so also add ap_str_toupper() function and use
it where possible.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1138617 13f79535-47bb-0310-9956-ffa450edef68
2011-06-22 20:24:27 +00:00