You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by sf...@apache.org on 2011/05/21 22:34:05 UTC
svn commit: r1125802 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h
include/ap_regex.h server/util_pcre.c
Author: sf
Date: Sat May 21 20:34:05 2011
New Revision: 1125802
URL: http://svn.apache.org/viewvc?rev=1125802&view=rev
Log:
Add ap_regexec_len() function that works with non-null-terminated
strings.
PR: 51231
Submitted by: Yehezkel Horowitz <horowity checkpoint com>, Stefan Fritsch
Modified:
httpd/httpd/trunk/CHANGES
httpd/httpd/trunk/include/ap_mmn.h
httpd/httpd/trunk/include/ap_regex.h
httpd/httpd/trunk/server/util_pcre.c
Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1125802&r1=1125801&r2=1125802&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Sat May 21 20:34:05 2011
@@ -2,6 +2,9 @@
Changes with Apache 2.3.13
+ *) core: Add ap_regexec_len() function that works with non-null-terminated
+ strings. PR 51231. [Yehezkel Horowitz <horowity checkpoint com>]
+
*) mod_authnz_ldap: If the LDAP server returns constraint violation,
don't treat this as an error but as "auth denied". [Stefan Fritsch]
Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1125802&r1=1125801&r2=1125802&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Sat May 21 20:34:05 2011
@@ -322,6 +322,7 @@
* 20110329.2 (2.3.12-dev) Add child_status and end_generation hooks.
* 20110329.3 (2.3.12-dev) Add format field to ap_errorlog_info.
* 20110329.4 (2.3.13-dev) bgrowth and max_balancers to proxy_server_conf.
+ * 20110329.5 (2.3.13-dev) Add ap_regexec_len()
*/
#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
@@ -329,7 +330,7 @@
#ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20110329
#endif
-#define MODULE_MAGIC_NUMBER_MINOR 4 /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 5 /* 0...n */
/**
* Determine if the server's current MODULE_MAGIC_NUMBER is at least a
Modified: httpd/httpd/trunk/include/ap_regex.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_regex.h?rev=1125802&r1=1125801&r2=1125802&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_regex.h (original)
+++ httpd/httpd/trunk/include/ap_regex.h Sat May 21 20:34:05 2011
@@ -124,6 +124,22 @@ AP_DECLARE(int) ap_regexec(const ap_rege
apr_size_t nmatch, ap_regmatch_t *pmatch, int eflags);
/**
+ * Match a string with given length against a pre-compiled regex. The string
+ * does not need to be NUL-terminated.
+ * @param preg The pre-compiled regex
+ * @param buff The string to match
+ * @param len Length of the string to match
+ * @param nmatch Provide information regarding the location of any matches
+ * @param pmatch Provide information regarding the location of any matches
+ * @param eflags Bitwise OR of AP_REG_* flags (NOTBOL and NOTEOL supported,
+ * other flags are ignored)
+ * @return 0 for successful match, AP_REG_NOMATCH otherwise
+ */
+AP_DECLARE(int) ap_regexec_len(const ap_regex_t *preg, const char *buff,
+ apr_size_t len, apr_size_t nmatch,
+ ap_regmatch_t *pmatch, int eflags);
+
+/**
* Return the error code returned by regcomp or regexec into error messages
* @param errcode the error code returned by regexec or regcomp
* @param preg The precompiled regex
Modified: httpd/httpd/trunk/server/util_pcre.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_pcre.c?rev=1125802&r1=1125801&r2=1125802&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_pcre.c (original)
+++ httpd/httpd/trunk/server/util_pcre.c Sat May 21 20:34:05 2011
@@ -152,11 +152,17 @@ the POSIX structures as was done in earl
ints. However, if the number of possible capturing brackets is small, use a
block of store on the stack, to reduce the use of malloc/free. The threshold is
in a macro that can be changed at configure time. */
-
AP_DECLARE(int) ap_regexec(const ap_regex_t *preg, const char *string,
- apr_size_t nmatch, ap_regmatch_t pmatch[],
+ apr_size_t nmatch, ap_regmatch_t *pmatch,
int eflags)
{
+return ap_regexec_len(preg, string, strlen(string), nmatch, pmatch, eflags);
+}
+
+AP_DECLARE(int) ap_regexec_len(const ap_regex_t *preg, const char *buff,
+ apr_size_t len, apr_size_t nmatch,
+ ap_regmatch_t *pmatch, int eflags)
+{
int rc;
int options = 0;
int *ovector = NULL;
@@ -182,7 +188,7 @@ if (nmatch > 0)
}
}
-rc = pcre_exec((const pcre *)preg->re_pcre, NULL, string, (int)strlen(string),
+rc = pcre_exec((const pcre *)preg->re_pcre, NULL, buff, (int)len,
0, options, ovector, nmatch * 3);
if (rc == 0) rc = nmatch; /* All captured slots were filled in */