[PATCH] lib: Return error if an incomplete message was read

Thomas Egerer hakke_007 at gmx.de
Thu Jun 4 05:43:58 PDT 2015


If recvmsg indicates that the message read was truncated libnl retries
to read the complete message after increasing the message buffer. This
only works if the message flags MSG_PEEK | MSG_TRUNC are set. If
NL_MSG_PEEK is not enabled on the nl_sock structure, flags are left
empty and the rest of the truncated message is discarded, hence a
subsequent recvmsg returns the next message (in case of a multipart
message, the NLMSG_DONE) is read and returned.
This patch aborts message processing if the message was truncated and
teh NL_MSG_PEEK flags was not activated for the nl_sock structure.

Signed-off-by: Thomas Egerer <hakke_007 at gmx.de>
---
Hello *,

I recently discovered a flaw in your library when reading large amounts
of data (larger than the 4096 byte buffer) without the NL_MSG_PEEK flag
set on the nl-socket. In this case the whole message is discarded while
the code suggests a reread. Example code for reproduction can be found
in [1].

[1] http://pastebin.com/hB1SAPrX

 lib/nl.c | 7 +++++++
 1 file changed, 7 insertions(+)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lib-Return-error-if-an-incomplete-message-was-read.patch
Type: text/x-patch
Size: 482 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/libnl/attachments/20150604/7657a621/attachment.bin>


More information about the libnl mailing list