diff options
author | Eric Blossom <eb@comsec.com> | 2010-05-19 20:27:10 -0700 |
---|---|---|
committer | Eric Blossom <eb@comsec.com> | 2010-05-19 20:27:10 -0700 |
commit | 4267b714f4276671f718136a1279f681a4231aee (patch) | |
tree | 3cfa0d610b113786fac9ae1bd55373e24ccbaf8e /gnuradio-core/src/lib | |
parent | 34e0be1f96cb24e302269c008444bc18e418b653 (diff) |
Defend against a peer that sends an invalid message length.
Diffstat (limited to 'gnuradio-core/src/lib')
-rwxr-xr-x | gnuradio-core/src/lib/io/gr_udp_source.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gnuradio-core/src/lib/io/gr_udp_source.cc b/gnuradio-core/src/lib/io/gr_udp_source.cc index f8727c4dc9..1197a0c436 100755 --- a/gnuradio-core/src/lib/io/gr_udp_source.cc +++ b/gnuradio-core/src/lib/io/gr_udp_source.cc @@ -281,6 +281,11 @@ gr_udp_source::work (int noutput_items, // This is a non-blocking call with a timeout set in the constructor r = recv(d_socket, d_temp_buff, d_payload_size, 0); // get the entire payload or the what's available + // If r > 0, round it down to a multiple of d_itemsize + // (If sender is broken, don't propagate problem) + if (r > 0) + r = (r/d_itemsize) * d_itemsize; + // Check if there was a problem; forget it if the operation just timed out if(r == -1) { if( is_error(EAGAIN) ) { // handle non-blocking call timeout |