You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by co...@locus.apache.org on 2000/08/11 16:41:13 UTC
cvs commit: apache-2.0/src/main http_request.c
coar 00/08/11 07:41:13
Modified: src/main http_request.c
Log:
Fix another oversight: don't add an extension method to the Allow
list if it's already there.
Revision Changes Path
1.41 +12 -0 apache-2.0/src/main/http_request.c
Index: http_request.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/main/http_request.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -u -r1.40 -r1.41
--- http_request.c 2000/08/10 11:22:57 1.40
+++ http_request.c 2000/08/11 14:41:13 1.41
@@ -1462,9 +1462,21 @@
* additional check of this array if it *is* invalid.
*/
if (mnum == M_INVALID) {
+ int i;
+ char **xmethods;
+
if (r->allowed_xmethods == NULL) {
r->allowed_xmethods = apr_make_array(r->pool, 2,
sizeof(char *));
+ }
+ /*
+ * Don't add it to the array if it's already listed.
+ */
+ xmethods = (char **) r->allowed_xmethods->elts;
+ for (i = 0; i < r->allowed_xmethods->nelts; ++i) {
+ if (strcmp(method, xmethods[i]) == 0) {
+ return;
+ }
}
xmethod = (const char **) apr_push_array(r->allowed_xmethods);
*xmethod = method;
Re: cvs commit: apache-2.0/src/main http_request.c
Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
Joe Orton wrote:
>
> Won't that skip the rest of the methods that were passed, if a single
> one has already been added?
Hork! True enough. Fixed, thanks!
--
#ken P-)}
Ken Coar <http://Golux.Com/coar/>
Apache Software Foundation <http://www.apache.org/>
"Apache Server for Dummies" <http://Apache-Server.Com/>
"Apache Server Unleashed" <http://ApacheUnleashed.Com/>
Re: cvs commit: apache-2.0/src/main http_request.c
Posted by Joe Orton <jo...@orton.demon.co.uk>.
On Fri, Aug 11, 2000 at 02:41:13PM -0000, coar@locus.apache.org wrote:
... in ap_allow_methods():
> + /*
> + * Don't add it to the array if it's already listed.
> + */
> + xmethods = (char **) r->allowed_xmethods->elts;
> + for (i = 0; i < r->allowed_xmethods->nelts; ++i) {
> + if (strcmp(method, xmethods[i]) == 0) {
> + return;
> + }
> }
Won't that skip the rest of the methods that were passed, if a single
one has already been added? How about:
Index: http_request.c
===================================================================
RCS file: /home/joe/lib/cvsroot/apache2/src/main/http_request.c,v
retrieving revision 1.41
diff -u -p -r1.41 http_request.c
--- http_request.c 2000/08/11 14:41:13 1.41
+++ http_request.c 2000/08/11 15:07:19
@@ -1462,7 +1462,7 @@ API_EXPORT(void) ap_allow_methods(reques
* additional check of this array if it *is* invalid.
*/
if (mnum == M_INVALID) {
- int i;
+ int i, found = 0;
char **xmethods;
if (r->allowed_xmethods == NULL) {
@@ -1475,11 +1475,14 @@ API_EXPORT(void) ap_allow_methods(reques
xmethods = (char **) r->allowed_xmethods->elts;
for (i = 0; i < r->allowed_xmethods->nelts; ++i) {
if (strcmp(method, xmethods[i]) == 0) {
- return;
+ found = 1;
+ break;
}
}
- xmethod = (const char **) apr_push_array(r->allowed_xmethods);
- *xmethod = method;
+ if (!found) {
+ xmethod = (const char **) apr_push_array(r->allowed_xmethods);
+ *xmethod = method;
+ }
}
}
}