Skip to content

Commit

Permalink
NTLM/Negotiate: Fix crash on bad helper TT responses (squid-cache#1645)
Browse files Browse the repository at this point in the history
Helper lookup may be made without a client HTTP Request,
(stored in lm_request->request). But in Helper::TT cases the
lm_request->request was dereferenced without any checks.
  • Loading branch information
jtstrs authored and squid-anubis committed Jan 23, 2024
1 parent 853de11 commit 87baadf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/auth/negotiate/UserRequest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,11 @@ Auth::Negotiate::UserRequest::HandleReply(void *data, const Helper::Reply &reply
case Helper::TT:
/* we have been given a blob to send to the client */
safe_free(lm_request->server_blob);
lm_request->request->flags.mustKeepalive = true;
if (lm_request->request->flags.proxyKeepalive) {

if (lm_request->request)
lm_request->request->flags.mustKeepalive = true;

if (lm_request->request && lm_request->request->flags.proxyKeepalive) {
const char *tokenNote = reply.notes.findFirst("token");
lm_request->server_blob = xstrdup(tokenNote);
auth_user_request->user()->credentials(Auth::Handshake);
Expand Down
7 changes: 5 additions & 2 deletions src/auth/ntlm/UserRequest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,11 @@ Auth::Ntlm::UserRequest::HandleReply(void *data, const Helper::Reply &reply)
case Helper::TT:
/* we have been given a blob to send to the client */
safe_free(lm_request->server_blob);
lm_request->request->flags.mustKeepalive = true;
if (lm_request->request->flags.proxyKeepalive) {

if (lm_request->request)
lm_request->request->flags.mustKeepalive = true;

if (lm_request->request && lm_request->request->flags.proxyKeepalive) {
const char *serverBlob = reply.notes.findFirst("token");
lm_request->server_blob = xstrdup(serverBlob);
auth_user_request->user()->credentials(Auth::Handshake);
Expand Down

0 comments on commit 87baadf

Please sign in to comment.