Skip to content
Snippets Groups Projects
Commit e87f5f02 authored by Steven Murray's avatar Steven Murray
Browse files

Better safe than sorry. Added a check for null and a check for dynamic

cast failure around the call to castor::io::ClientSocket::readObject() within
the function castor::tape::aggregator::Transceiver::tellGatewayToStartWorker()
parent dadbcf1a
Branches
Tags
No related merge requests found
......@@ -979,8 +979,30 @@ void castor::tape::aggregator::Transceiver::tellGatewayToStartWorker(
castor::io::ClientSocket socket(gatewayPort, gatewayhost);
castor::IObject *obj = socket.readObject();
if(obj == NULL) {
castor::exception::Exception ex(EINVAL);
ex.getMessage() << __PRETTY_FUNCTION__
<< ": Failed to get StartTransferResponse from tape gateway"
": ClientSocket::readObject() returned null";
throw ex;
}
std::auto_ptr<tapegateway::StartWorkerResponse> response(
dynamic_cast<tapegateway::StartWorkerResponse*>(socket.readObject()));
dynamic_cast<tapegateway::StartWorkerResponse*>(obj));
if(response.get() == NULL) {
castor::exception::Exception ex(EINVAL);
ex.getMessage() << __PRETTY_FUNCTION__
<< ": Failed to get StartTransferResponse from tape gateway"
": Failed to dynamic cast StartTransferResponse";
throw ex;
}
gatewayErrorCode = response->errorCode();
gatewayErrorMsg = response->errorMessage();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment