1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 17:51:22 +03:00

bus: fix leak in error path

CID #1271349.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2015-03-07 15:05:50 -05:00
parent 2558691285
commit bcf88fc3f1
Notes: Lennart Poettering 2015-05-21 17:53:34 +02:00
Backport: bugfix

View File

@ -440,7 +440,7 @@ int bus_message_from_header(
size_t extra, size_t extra,
sd_bus_message **ret) { sd_bus_message **ret) {
sd_bus_message *m; _cleanup_free_ sd_bus_message *m = NULL;
struct bus_header *h; struct bus_header *h;
size_t a, label_sz; size_t a, label_sz;
@ -459,15 +459,13 @@ int bus_message_from_header(
return -EBADMSG; return -EBADMSG;
h = header; h = header;
if (h->version != 1 && if (!IN_SET(h->version, 1, 2))
h->version != 2)
return -EBADMSG; return -EBADMSG;
if (h->type == _SD_BUS_MESSAGE_TYPE_INVALID) if (h->type == _SD_BUS_MESSAGE_TYPE_INVALID)
return -EBADMSG; return -EBADMSG;
if (h->endian != BUS_LITTLE_ENDIAN && if (!IN_SET(h->endian, BUS_LITTLE_ENDIAN, BUS_BIG_ENDIAN))
h->endian != BUS_BIG_ENDIAN)
return -EBADMSG; return -EBADMSG;
/* Note that we are happy with unknown flags in the flags header! */ /* Note that we are happy with unknown flags in the flags header! */
@ -556,6 +554,7 @@ int bus_message_from_header(
m->bus = sd_bus_ref(bus); m->bus = sd_bus_ref(bus);
*ret = m; *ret = m;
m = NULL;
return 0; return 0;
} }