chiark / gitweb /
bus: properly handle empty messages
[elogind.git] / src / libsystemd-bus / bus-message.c
index f01f8b15bc213cc66e531c9e2e99a3f3c6576a75..9e712717cc34b31864af3e5d97953cc52dac2539 100644 (file)
@@ -1894,9 +1894,7 @@ _public_ int sd_bus_message_open_container(
 }
 
 static size_t determine_word_size(size_t sz, size_t extra) {
-        if (sz <= 0 && extra == 0)
-                return 0;
-        else if (sz + extra <= 0xFF)
+        if (sz + extra <= 0xFF)
                 return 1;
         else if (sz + extra*2 <= 0xFFFF)
                 return 2;
@@ -3063,7 +3061,7 @@ static int message_peek_body(
         }
 
         part = find_part(m, start, nbytes, (void**) &q);
-        if (!part || !q)
+        if (!part || (nbytes > 0 && !q))
                 return -EBADMSG;
 
         *rindex = end;
@@ -5085,9 +5083,6 @@ int bus_message_parse_fields(sd_bus_message *m) {
         if (m->n_fds != unix_fds)
                 return -EBADMSG;
 
-        if (isempty(m->root_container.signature) != (BUS_MESSAGE_BODY_SIZE(m) == 0))
-                return -EBADMSG;
-
         switch (m->header->type) {
 
         case SD_BUS_MESSAGE_SIGNAL: