/*
- * $Id: auth_negotiate.cc,v 1.5 2005/11/06 21:50:14 hno Exp $
+ * $Id: auth_negotiate.cc,v 1.6 2005/11/06 22:50:25 hno Exp $
*
* DEBUG: section 29 Negotiate Authenticator
* AUTHOR: Robert Collins, Henrik Nordstrom, Francesco Chemolli
if (!reply) {
debug(29, 1) ("authenticateNegotiateHandleReply: Helper '%p' crashed!.\n", lastserver);
- reply = "BH Internal error";
+ reply = (char *)"BH Internal error";
}
auth_user_request = r->auth_user_request;
/* seperate out the useful data */
blob = strchr(reply, ' ');
- while (blob && xisspace(*blob)) { // trim leading spaces in blob
+ if (blob) {
blob++;
arg = strchr(blob + 1, ' ');
+ } else {
+ arg = NULL;
}
- if (strncasecmp(reply, "TT ", 3) == 0 && blob != NULL) {
+ if (strncasecmp(reply, "TT ", 3) == 0) {
/* we have been given a blob to send to the client */
if (arg)
debug(29, 4) ("authenticateNegotiateHandleReply: Need to challenge the client with a server blob '%s'\n", blob);
result = S_HELPER_RESERVE;
- } else if (strncasecmp(reply, "AF ", 3) == 0 && blob != NULL) {
+ } else if (strncasecmp(reply, "AF ", 3) == 0 && arg != NULL) {
/* we're finished, release the helper */
if (arg)
result = S_HELPER_RELEASE;
debug(29, 4) ("authenticateNegotiateHandleReply: Successfully validated user via NEGOTIATE. Username '%s'\n", blob);
- } else if (strncasecmp(reply, "NA ", 3) == 0 && blob != NULL) {
+ } else if (strncasecmp(reply, "NA ", 3) == 0 && arg != NULL) {
/* authentication failure (wrong password, etc.) */
if (arg)
/* get header */
proxy_auth = httpHeaderGetStr(&request->header, type);
- blob = proxy_auth + strlen("Negotiate");
+ /* locate second word */
+ blob = proxy_auth;
+
+ while (xisspace(*blob) && *blob)
+ blob++;
+
+ while (!xisspace(*blob) && *blob)
+ blob++;
- while (xisspace(*blob)) // trim leading spaces in blob
+ while (xisspace(*blob) && *blob)
blob++;
switch (auth_state) {
/*
- * $Id: auth_ntlm.cc,v 1.53 2005/11/06 21:50:14 hno Exp $
+ * $Id: auth_ntlm.cc,v 1.54 2005/11/06 22:50:25 hno Exp $
*
* DEBUG: section 29 NTLM Authenticator
* AUTHOR: Robert Collins, Henrik Nordstrom, Francesco Chemolli
if (!reply) {
debug(29, 1) ("authenticateNTLMHandleReply: Helper '%p' crashed!.\n", lastserver);
- reply = "BH Internal error";
+ reply = (char *)"BH Internal error";
}
auth_user_request = r->auth_user_request;
/* seperate out the useful data */
blob = strchr(reply, ' ');
- while (blob && xisspace(*blob)) { // trim leading spaces in blob
+ if (blob)
blob++;
- }
- if (strncasecmp(reply, "TT ", 3) == 0 && blob != NULL) {
+ if (strncasecmp(reply, "TT ", 3) == 0) {
/* we have been given a blob to send to the client */
safe_free(ntlm_request->server_blob);
ntlm_request->server_blob = xstrdup(blob);
auth_user_request->denyMessage("Authenication in progress");
debug(29, 4) ("authenticateNTLMHandleReply: Need to challenge the client with a server blob '%s'\n", blob);
result = S_HELPER_RESERVE;
- } else if (strncasecmp(reply, "AF ", 3) == 0 && blob != NULL) {
+ } else if (strncasecmp(reply, "AF ", 3) == 0) {
/* we're finished, release the helper */
ntlm_user->username(blob);
auth_user_request->denyMessage("Login successful");
result = S_HELPER_RELEASE;
debug(29, 4) ("authenticateNTLMHandleReply: Successfully validated user via NTLM. Username '%s'\n", blob);
- } else if (strncasecmp(reply, "NA ", 3) == 0 && blob != NULL) {
+ } else if (strncasecmp(reply, "NA ", 3) == 0) {
/* authentication failure (wrong password, etc.) */
auth_user_request->denyMessage(blob);
ntlm_request->auth_state = AUTHENTICATE_STATE_FAILED;
/* get header */
proxy_auth = httpHeaderGetStr(&request->header, type);
- blob = proxy_auth + strlen("NTLM");
+ /* locate second word */
+ blob = proxy_auth;
+
+ while (xisspace(*blob) && *blob)
+ blob++;
+
+ while (!xisspace(*blob) && *blob)
+ blob++;
- while (xisspace(*blob)) // trim leading spaces in blob
+ while (xisspace(*blob) && *blob)
blob++;
switch (auth_state) {