summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Orton <notroj@users.noreply.github.com>2007-07-14 09:03:40 +0000
committerJoe Orton <notroj@users.noreply.github.com>2007-07-14 09:03:40 +0000
commit6a4cb2e4f865b81073a223ef8529c25a2668bf6c (patch)
tree32d621bf2745beb7a7967d08985415624bbeadce
parent6a5a398746fd94a47f4a2d7b50954bd0634738ed (diff)
downloadneon-git-6a4cb2e4f865b81073a223ef8529c25a2668bf6c.tar.gz
Merge r1187, r1188 from trunk:
* src/ne_auth.c (auth_register): Fix multiple handler use (Werner Baumann) * test/auth.c (multi_cb, multi_handler): New test case. * test/auth.c (multi_handler): Use any_request().
-rw-r--r--NEWS1
-rw-r--r--src/ne_auth.c2
-rw-r--r--test/auth.c52
3 files changed, 54 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 946205e..19b903e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
Changes in release 0.26.4:
* Fix If: header insertion by ne_lock* to use CRLF-terminated headers
* Fix Negotiate Authentication-Info response header verification with GSSAPI
+* Fix multiple handlers with ne_add_{server,proxy}_auth (Werner Baumann)
* Fix SSPI build with some versions of MinGW (Gisle Vanem)
* Fix for SSPI segfault in response header verification (Mike Dicuccio)
* Fix error strings for CONNECT SSL proxy tunnel request failure
diff --git a/src/ne_auth.c b/src/ne_auth.c
index 9c72596..8def3e0 100644
--- a/src/ne_auth.c
+++ b/src/ne_auth.c
@@ -1317,7 +1317,7 @@ static void auth_register(ne_session *sess, int isproxy, unsigned protomask,
/* Find the end of the handler list, and add a new one. */
hdl = &ahs->handlers;
- while (*hdl && (*hdl)->next)
+ while (*hdl)
hdl = &(*hdl)->next;
*hdl = ne_malloc(sizeof **hdl);
diff --git a/test/auth.c b/test/auth.c
index 9468a51..98a1101 100644
--- a/test/auth.c
+++ b/test/auth.c
@@ -892,6 +892,57 @@ static int fail_challenge(void)
return OK;
}
+struct multi_context {
+ int id;
+ ne_buffer *buf;
+};
+
+static int multi_cb(void *userdata, const char *realm, int tries,
+ char *un, char *pw)
+{
+ struct multi_context *ctx = userdata;
+ char buf[128];
+
+ ne_snprintf(buf, sizeof buf, "[id=%d, realm=%s, tries=%d]",
+ ctx->id, realm, tries);
+ ne_buffer_zappend(ctx->buf, buf);
+
+ return -1;
+}
+
+static int multi_handler(void)
+{
+ ne_session *sess;
+ struct multi_context c[2];
+ unsigned n;
+ ne_buffer *buf = ne_buffer_create();
+
+ CALL(make_session(&sess, single_serve_string,
+ "HTTP/1.1 401 Auth Denied\r\n"
+ "WWW-Authenticate: Basic realm='fish',"
+ " Digest realm='food', algorithm=MD5, qop=auth, nonce=gaga\r\n"
+ "Content-Length: 0\r\n" "\r\n"));
+
+ for (n = 0; n < 2; n++) {
+ c[n].buf = buf;
+ c[n].id = n + 1;
+ }
+
+ ne_add_server_auth(sess, NE_AUTH_BASIC, multi_cb, &c[0]);
+ ne_add_server_auth(sess, NE_AUTH_DIGEST, multi_cb, &c[1]);
+
+ any_request(sess, "/fish");
+
+ ONCMP("[id=2, realm=food, tries=0]"
+ "[id=1, realm=fish, tries=0]", buf->data,
+ "multiple callback", "invocation order");
+
+ ne_session_destroy(sess);
+ ne_buffer_destroy(buf);
+
+ return await_server();
+}
+
/* test logout */
/* proxy auth, proxy AND origin */
@@ -906,5 +957,6 @@ ne_test tests[] = {
T(digest),
T(digest_failures),
T(fail_challenge),
+ T(multi_handler),
T(NULL)
};