--------------------- PatchSet 10434 Date: 2008/01/25 09:47:11 Author: adri Branch: s27_adri Tag: (none) Log: Convert the authentication code to the new string code. Members: src/auth/negotiate/auth_negotiate.c:1.13.10.1->1.13.10.2 Index: squid/src/auth/negotiate/auth_negotiate.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/auth/negotiate/auth_negotiate.c,v retrieving revision 1.13.10.1 retrieving revision 1.13.10.2 diff -u -r1.13.10.1 -r1.13.10.2 --- squid/src/auth/negotiate/auth_negotiate.c 20 Dec 2007 10:35:28 -0000 1.13.10.1 +++ squid/src/auth/negotiate/auth_negotiate.c 25 Jan 2008 09:47:11 -0000 1.13.10.2 @@ -1,6 +1,6 @@ /* - * $Id: auth_negotiate.c,v 1.13.10.1 2007/12/20 10:35:28 adri Exp $ + * $Id: auth_negotiate.c,v 1.13.10.2 2008/01/25 09:47:11 adri Exp $ * * DEBUG: section 29 Negotiate Authenticator * AUTHOR: Robert Collins @@ -313,7 +313,7 @@ httpHeaderPutStrf(&rep->header, type, "Negotiate"); if (!negotiateConfig->keep_alive) { /* drop the connection */ - httpHeaderDelByName(&rep->header, "keep-alive"); + httpHeaderDelByNameCstr(&rep->header, "keep-alive"); request->flags.proxy_keepalive = 0; } return; @@ -325,7 +325,7 @@ debug(29, 9) ("authenticateNegotiateFixErrorHeader: Sending type:%d header: 'Negotiate'\n", type); httpHeaderPutStrf(&rep->header, type, "Negotiate"); /* drop the connection */ - httpHeaderDelByName(&rep->header, "keep-alive"); + httpHeaderDelByNameCstr(&rep->header, "keep-alive"); request->flags.proxy_keepalive = 0; break; case AUTHENTICATE_STATE_NEGOTIATE: @@ -695,7 +695,8 @@ static void authenticateNegotiateAuthenticateUser(auth_user_request_t * auth_user_request, request_t * request, ConnStateData * conn, http_hdr_type type) { - const char *proxy_auth, *blob; + String *proxy_auth; + int pa = 0; auth_user_t *auth_user; negotiate_request_t *negotiate_request; negotiate_user_t *negotiate_user; @@ -723,22 +724,21 @@ return; } /* get header */ - proxy_auth = httpHeaderGetStr(&request->header, type); - blob = proxy_auth; - while (xisspace(*blob) && *blob) - blob++; - while (!xisspace(*blob) && *blob) - blob++; - while (xisspace(*blob) && *blob) - blob++; + proxy_auth = httpHeaderGetString(&request->header, type); + while (pa < strLen2(*proxy_auth) && xisspace(strGetPos(*proxy_auth, pa))) + pa++; + while (pa < strLen2(*proxy_auth) && (!xisspace(strGetPos(*proxy_auth, pa)))) + pa++; + while (pa < strLen2(*proxy_auth) && xisspace(strGetPos(*proxy_auth, pa))) + pa++; switch (negotiate_request->auth_state) { case AUTHENTICATE_STATE_NONE: /* we've received a negotiate request. pass to a helper */ - debug(29, 9) ("authenticateNegotiateAuthenticateUser: auth state negotiate none. %s\n", proxy_auth); + debug(29, 9) ("authenticateNegotiateAuthenticateUser: auth state negotiate none. %.*s\n", strLen2(*proxy_auth), strBuf2(*proxy_auth)); negotiate_request->auth_state = AUTHENTICATE_STATE_INITIAL; safe_free(negotiate_request->client_blob); - negotiate_request->client_blob = xstrdup(blob); + negotiate_request->client_blob = strCDupOffset(*proxy_auth, pa); conn->auth_type = AUTH_NEGOTIATE; conn->auth_user_request = auth_user_request; negotiate_request->conn = conn; @@ -755,12 +755,12 @@ case AUTHENTICATE_STATE_NEGOTIATE: /* we should have received a blob from the clien. pass it to the same * helper process */ - debug(29, 9) ("authenticateNegotiateAuthenticateUser: auth state challenge with header %s.\n", proxy_auth); + debug(29, 9) ("authenticateNegotiateAuthenticateUser: auth state challenge with header %.*s.\n", strLen2(*proxy_auth), strBuf2(*proxy_auth)); /* do a cache lookup here. If it matches it's a successful negotiate * challenge - release the helper and use the existing auth_user * details. */ safe_free(negotiate_request->client_blob); - negotiate_request->client_blob = xstrdup(blob); + negotiate_request->client_blob = strCDupOffset(*proxy_auth, pa); if (negotiate_request->request) requestUnlink(negotiate_request->request); negotiate_request->request = requestLink(request); @@ -771,7 +771,7 @@ break; case AUTHENTICATE_STATE_FAILED: /* we've failed somewhere in authentication */ - debug(29, 9) ("authenticateNegotiateAuthenticateUser: auth state negotiate failed. %s\n", proxy_auth); + debug(29, 9) ("authenticateNegotiateAuthenticateUser: auth state negotiate failed. %.*s\n", strLen2(*proxy_auth), strBuf2(*proxy_auth)); return; } return;