bus: handle serialization of NULL strings
Instead of simply crashing be somewhat nicer and serialize a NULL string into the empty string and generate an error on signature and object path strings.
This commit is contained in:
parent
41f85451d3
commit
cd6f997f71
|
@ -1347,14 +1347,29 @@ int message_append_basic(sd_bus_message *m, char type, const void *p, const void
|
|||
switch (type) {
|
||||
|
||||
case SD_BUS_TYPE_STRING:
|
||||
/* To make things easy we'll serialize a NULL string
|
||||
* into the empty string */
|
||||
p = strempty(p);
|
||||
|
||||
/* Fall through... */
|
||||
case SD_BUS_TYPE_OBJECT_PATH:
|
||||
|
||||
if (!p) {
|
||||
r = -EINVAL;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
align = 4;
|
||||
sz = 4 + strlen(p) + 1;
|
||||
break;
|
||||
|
||||
case SD_BUS_TYPE_SIGNATURE:
|
||||
|
||||
if (!p) {
|
||||
r = -EINVAL;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
align = 1;
|
||||
sz = 1 + strlen(p) + 1;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue