summaryrefslogtreecommitdiff
path: root/lib/nl.c
diff options
context:
space:
mode:
authorThomas Egerer <hakke_007@gmx.de>2015-06-04 14:43:58 +0200
committerThomas Haller <thaller@redhat.com>2015-06-05 08:40:02 +0200
commitbbdcaea9a779885fedc04817dcc11953a377bfd5 (patch)
treea498d229e236c8fd01b2be85fbd88deef3e7c4d4 /lib/nl.c
parente206c255d8fff8b51938945c8f575750c418a95e (diff)
downloadlibnl-bbdcaea9a779885fedc04817dcc11953a377bfd5.tar.gz
lib: return error if an incomplete message was read
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 the NL_MSG_PEEK flags was not activated for the nl_sock structure. http://lists.infradead.org/pipermail/libnl/2015-June/001888.html [thaller@redhat.com: add NL_CAPABILITY_NL_RECV_FAIL_TRUNK_NO_PEEK] Signed-off-by: Thomas Egerer <hakke_007@gmx.de> Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'lib/nl.c')
-rw-r--r--lib/nl.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/nl.c b/lib/nl.c
index 8fc9ec10..f06e9a0a 100644
--- a/lib/nl.c
+++ b/lib/nl.c
@@ -725,6 +725,13 @@ retry:
if (iov.iov_len < n || (msg.msg_flags & MSG_TRUNC)) {
void *tmp;
+
+ /* respond with error to an incomplete message */
+ if (!(sk->s_flags & NL_MSG_PEEK)) {
+ retval = -NLE_MSG_TRUNC;
+ goto abort;
+ }
+
/* Provided buffer is not long enough, enlarge it
* to size of n (which should be total length of the message)
* and try again. */