chiark / gitweb /
sd-bus: don't choke if somebody sends us a message with a unix fd count of 0
authorLennart Poettering <lennart@poettering.net>
Fri, 14 Mar 2014 20:15:32 +0000 (21:15 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 14 Mar 2014 20:17:14 +0000 (21:17 +0100)
It's kinda pointless to include a unix fd header field in messages if it
carries the value 0, but let's do this anyway...

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

index 97ab0e3..b9d7f6d 100644 (file)
@@ -4885,6 +4885,7 @@ int bus_message_parse_fields(sd_bus_message *m) {
         size_t ri;
         int r;
         uint32_t unix_fds = 0;
+        bool unix_fds_set = false;
         void *offsets = NULL;
         unsigned n_offsets = 0;
         size_t sz = 0;
@@ -5097,7 +5098,7 @@ int bus_message_parse_fields(sd_bus_message *m) {
                 }
 
                 case BUS_MESSAGE_HEADER_UNIX_FDS:
-                        if (unix_fds != 0)
+                        if (unix_fds_set)
                                 return -EBADMSG;
 
                         if (!streq(signature, "u"))
@@ -5107,9 +5108,7 @@ int bus_message_parse_fields(sd_bus_message *m) {
                         if (r < 0)
                                 return -EBADMSG;
 
-                        if (unix_fds == 0)
-                                return -EBADMSG;
-
+                        unix_fds_set = true;
                         break;
 
                 default: