aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hilburn <ben.hilburn@ettus.com>2014-03-14 13:59:46 -0700
committerBen Hilburn <ben.hilburn@ettus.com>2014-03-14 13:59:46 -0700
commit5e4bc88394d8591ed3c2ab88cbfbc8df82263133 (patch)
treef99238fd77c29bb80f5e9071dc2a66fe15b95bd3
parent79e038bc8691d838891377cf6b6123b1ab57a4ca (diff)
parent1d459fa2fbbc9217c9189589077536eba26724c3 (diff)
downloaduhd-5e4bc88394d8591ed3c2ab88cbfbc8df82263133.tar.gz
uhd-5e4bc88394d8591ed3c2ab88cbfbc8df82263133.tar.bz2
uhd-5e4bc88394d8591ed3c2ab88cbfbc8df82263133.zip
Merging fix for NULL pointer deref in rpc_client::call()
-rw-r--r--host/lib/transport/nirio/rpc/rpc_client.cpp32
1 files changed, 20 insertions, 12 deletions
diff --git a/host/lib/transport/nirio/rpc/rpc_client.cpp b/host/lib/transport/nirio/rpc/rpc_client.cpp
index c16a844c1..f8dc26b50 100644
--- a/host/lib/transport/nirio/rpc/rpc_client.cpp
+++ b/host/lib/transport/nirio/rpc/rpc_client.cpp
@@ -133,9 +133,12 @@ const boost::system::error_code& rpc_client::call(
CHAIN_BLOCKING_XFER(
boost::asio::write(_socket, boost::asio::buffer(&_request.header, sizeof(_request.header))),
sizeof(_request.header), status);
- CHAIN_BLOCKING_XFER(
- boost::asio::write(_socket, boost::asio::buffer(&(*_request.data.begin()), _request.data.size())),
- _request.data.size(), status);
+ if (not _request.data.empty())
+ {
+ CHAIN_BLOCKING_XFER(
+ boost::asio::write(_socket, boost::asio::buffer(&(*_request.data.begin()), _request.data.size())),
+ _request.data.size(), status);
+ }
} catch (boost::exception&) {
status = false;
}
@@ -171,15 +174,20 @@ void rpc_client::_handle_response_hdr(const boost::system::error_code& err, size
if (!_exec_err && (transferred == expected)) {
//Response header received. Verify that it is expected
if (func_args_header_t::match_function(_request.header, _response.header)) {
- _response.data.resize(_response.header.func_args_size);
-
- //Wait for response data
- boost::asio::async_read(_socket,
- boost::asio::buffer(&(*_response.data.begin()), _response.data.size()),
- boost::bind(&rpc_client::_handle_response_data, this,
- boost::asio::placeholders::error,
- boost::asio::placeholders::bytes_transferred,
- _response.data.size()));
+ if (_response.header.func_args_size)
+ {
+ _response.data.resize(_response.header.func_args_size);
+
+ //Wait for response data
+ boost::asio::async_read(_socket,
+ boost::asio::buffer(&(*_response.data.begin()), _response.data.size()),
+ boost::bind(&rpc_client::_handle_response_data, this,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ _response.data.size()));
+ } else {
+ _handle_response_data(err, 0, 0);
+ }
} else {
//Unexpected response. Ignore it.
UHD_LOG << "rpc_client received garbage responses." << std::endl;