Better handling of unsupported requests.

This commit is contained in:
Max Goedjen 2020-03-22 15:50:40 -07:00
parent 4934c41d22
commit 6b40b392ef
No known key found for this signature in database
GPG Key ID: E58C21DD77B9B8E8
2 changed files with 6 additions and 2 deletions

View File

@ -26,7 +26,11 @@ extension Agent {
let data = reader.availableData
guard !data.isEmpty else { return }
let requestTypeInt = data[4]
guard let requestType = SSHAgent.RequestType(rawValue: requestTypeInt) else { return }
guard let requestType = SSHAgent.RequestType(rawValue: requestTypeInt) else {
writer.write(SSHAgent.ResponseType.agentFailure.data)
os_log(.debug, "Agent returned %@", SSHAgent.ResponseType.agentFailure.debugDescription)
return
}
os_log(.debug, "Agent handling request of type %@", requestType.debugDescription)
let subData = Data(data[5...])
let response = handle(requestType: requestType, data: subData, reader: reader)

View File

@ -12,7 +12,7 @@ extension SSHAgent {
switch self {
case .requestIdentities:
return "RequestIdentities"
default:
case .signRequest:
return "SignRequest"
}
}