]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Use the correct HTTP method when generating our digest, otherwise we always fail.
authorSean Bright <sean@malleable.com>
Thu, 5 May 2011 02:30:45 +0000 (02:30 +0000)
committerSean Bright <sean@malleable.com>
Thu, 5 May 2011 02:30:45 +0000 (02:30 +0000)
When calculating the 'A2' portion of our digest for verification, we need the
HTTP method that is currently in use.  Unfortunately our mapping function was
incorrect, resulting in invalid hashes being generated and, in turn, failures
in authentication.

(closes issue #18598)
Reported by: ksn

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@316919 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/http.c

index 592367f1e8e36b704ec0f5e83ad488566507d0f1..68c0765b19028ae2f6f7235ceb419e444fb53933 100644 (file)
@@ -132,7 +132,7 @@ static AST_RWLIST_HEAD_STATIC(uri_redirects, http_uri_redirect);
 
 static const struct ast_cfhttp_methods_text {
        enum ast_http_method method;
-       const char text[];
+       const char *text;
 } ast_http_methods_text[] = {
        { AST_HTTP_UNKNOWN,     "UNKNOWN" },
        { AST_HTTP_GET,         "GET" },
@@ -143,7 +143,15 @@ static const struct ast_cfhttp_methods_text {
 
 const char *ast_get_http_method(enum ast_http_method method)
 {
-       return ast_http_methods_text[method].text;
+       int x;
+
+       for (x = 0; x < ARRAY_LEN(ast_http_methods_text); x++) {
+               if (ast_http_methods_text[x].method == method) {
+                       return ast_http_methods_text[x].text;
+               }
+       }
+
+       return NULL;
 }
 
 const char *ast_http_ftype2mtype(const char *ftype)