httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <...@orton.demon.co.uk>
Subject Re: cvs commit: apache-2.0/src/main http_request.c
Date Fri, 11 Aug 2000 15:27:41 GMT
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;
+	    }
 	}
     }
 }






Mime
View raw message