chiark / gitweb /
rtnl: message - move code around
authorTom Gundersen <teg@jklm.no>
Sat, 10 May 2014 17:40:11 +0000 (19:40 +0200)
committerTom Gundersen <teg@jklm.no>
Sat, 10 May 2014 18:56:37 +0000 (20:56 +0200)
No functional change.

src/libsystemd/sd-rtnl/rtnl-message.c

index d611207..fb42986 100644 (file)
@@ -1154,10 +1154,6 @@ int socket_read_message(sd_rtnl *rtnl) {
         else
                 len = (size_t)r;
 
-        if (len > rtnl->rbuffer_allocated)
-                /* message did not fit in read buffer */
-                return -EIO;
-
         for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
                 if (cmsg->cmsg_level == SOL_SOCKET &&
                     cmsg->cmsg_type == SCM_CREDENTIALS &&
@@ -1176,6 +1172,10 @@ int socket_read_message(sd_rtnl *rtnl) {
                 /* not from the kernel, ignore */
                 return 0;
 
+        if (len > rtnl->rbuffer_allocated)
+                /* message did not fit in read buffer */
+                return -EIO;
+
         if (NLMSG_OK(rtnl->rbuffer, len) && rtnl->rbuffer->nlmsg_flags & NLM_F_MULTI) {
                 multi_part = true;