diff options
author | Nathaniel McCallum <npmccallum@redhat.com> | 2016-06-21 16:12:36 -0400 |
---|---|---|
committer | Tom Yu <tlyu@mit.edu> | 2016-07-06 16:22:34 -0400 |
commit | c0a12661789ac536f0657506f0541dfb4d8a0cd9 (patch) | |
tree | 1e68247d2d1908783d2230b8cd255b761d5f5635 | |
parent | ed725b8e0f43d8e6cf0ebe4eea89edabef1eba3d (diff) | |
download | krb5-c0a12661789ac536f0657506f0541dfb4d8a0cd9.zip krb5-c0a12661789ac536f0657506f0541dfb4d8a0cd9.tar.gz krb5-c0a12661789ac536f0657506f0541dfb4d8a0cd9.tar.bz2 |
Fix incorrect recv() size calculation in libkrad
Before this patch libkrad would always subtract the existing buffer
length from pktlen before passing it to recv(). In the case of stream
sockets, this is incorrect since krad_packet_bytes_needed() already
performs this calculation. Subtracting the buffer length twice could
cause integer underflow on the len parameter to recv().
(cherry picked from commit c969e8a37617e9c7743a28177dd3808f7d08cee9)
ticket: 8430
version_fixed: 1.14.3
-rw-r--r-- | src/lib/krad/remote.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/krad/remote.c b/src/lib/krad/remote.c index aaabffd..df3de3a 100644 --- a/src/lib/krad/remote.c +++ b/src/lib/krad/remote.c @@ -315,7 +315,7 @@ on_io_read(krad_remote *rr) request *tmp, *r; int i; - pktlen = sizeof(rr->buffer_); + pktlen = sizeof(rr->buffer_) - rr->buffer.length; if (rr->info->ai_socktype == SOCK_STREAM) { pktlen = krad_packet_bytes_needed(&rr->buffer); if (pktlen < 0) { @@ -328,7 +328,7 @@ on_io_read(krad_remote *rr) /* Read the packet. */ i = recv(verto_get_fd(rr->io), rr->buffer.data + rr->buffer.length, - pktlen - rr->buffer.length, 0); + pktlen, 0); if (i < 0) { /* Should we try again? */ if (errno == EWOULDBLOCK || errno == EAGAIN || errno == EINTR) |