Skip to content

Commit

Permalink
Correct fast-path handshake length calculation.
Browse files Browse the repository at this point in the history
Prevent segv when encryption is not available.
  • Loading branch information
abh3 committed Oct 13, 2016
1 parent a7a27eb commit fa86c92
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/XrdSec/XrdSecProtect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,10 @@ const char *XrdSecProtect::Verify(SecurityRequest &secreq,
if (rc < 0) return strerror(-rc);
if (myReq.bP->size != (int)sizeof(secHash))
return "Invalid signature hash length";
inHash = (unsigned char *)myReq.bP->buffer;
} else {
if (dlen != (int)sizeof(secHash))
return "Invalid signature hash length";
}

// Fill out the iovec to recompute the hash
Expand All @@ -443,7 +447,7 @@ const char *XrdSecProtect::Verify(SecurityRequest &secreq,

// Compare this hash with the hash we were given
//
if (memcmp(secHash, myReq.bP->buffer, sizeof(secHash)))
if (memcmp(secHash, inHash, sizeof(secHash)))
return "Signature hash mismatch";

// This request has been verified (update the seqno)
Expand Down
4 changes: 2 additions & 2 deletions src/XrdXrootd/XrdXrootdProtocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,10 @@ int dlen, rc;
memcpy(&Request, hsRqst, sizeof(Request));
memcpy(hsprot.Hdr.streamid,hsRqst->streamid,sizeof(hsprot.Hdr.streamid));
rspLen = do_Protocol(&hsprot.Rsp);
iov[1].iov_len = rspLen;
hsprot.Hdr.dlen = htonl(rspLen);
hsprot.Hdr.status = 0;
rc = lp->Send(iov, 2, sizeof(hsresp)+rspLen);
iov[1].iov_len = sizeof(hsprot.Hdr) + rspLen;
rc = lp->Send(iov, 2, sizeof(hsresp)+sizeof(hsprot.Hdr)+rspLen);
}

// Verify that our handshake response was actually sent
Expand Down

0 comments on commit fa86c92

Please sign in to comment.