mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-02 09:47:03 +03:00
sd-bus: refuse to send messages with an invalid string
Prompted by aaf7b0e41105d7b7cf30912cdac32820f011a219 and 4804da58536ab7ad46178a03f4d2da49fd8e4ba2.
This commit is contained in:
parent
e9dbe2abc3
commit
26a9dd6f55
@ -1342,12 +1342,21 @@ int message_append_basic(sd_bus_message *m, char type, const void *p, const void
|
|||||||
* into the empty string */
|
* into the empty string */
|
||||||
p = strempty(p);
|
p = strempty(p);
|
||||||
|
|
||||||
_fallthrough_;
|
if (!utf8_is_valid(p))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
align = 4;
|
||||||
|
sz = 4 + strlen(p) + 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case SD_BUS_TYPE_OBJECT_PATH:
|
case SD_BUS_TYPE_OBJECT_PATH:
|
||||||
|
|
||||||
if (!p)
|
if (!p)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (!object_path_is_valid(p))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
align = 4;
|
align = 4;
|
||||||
sz = 4 + strlen(p) + 1;
|
sz = 4 + strlen(p) + 1;
|
||||||
break;
|
break;
|
||||||
@ -1356,6 +1365,9 @@ int message_append_basic(sd_bus_message *m, char type, const void *p, const void
|
|||||||
|
|
||||||
p = strempty(p);
|
p = strempty(p);
|
||||||
|
|
||||||
|
if (!signature_is_valid(p, /* allow_dict_entry = */ true))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
align = 1;
|
align = 1;
|
||||||
sz = 1 + strlen(p) + 1;
|
sz = 1 + strlen(p) + 1;
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user