bus: add some minimal bounds check on signatures

CID#1491292
CID#1491291
CID#1491290
CID#1491289
CID#1491284
CID#1491281
CID#1491280
CID#1491278
This commit is contained in:
Luca Boccassi
2023-07-16 11:32:54 +01:00
parent 5f03212abb
commit d80cc39558
2 changed files with 10 additions and 1 deletions
+4 -1
View File
@@ -1627,8 +1627,11 @@ static int message_append_cmdline(sd_bus_message *m, const char *signature, char
p--;
r = signature_element_length(signature, &k);
if (r < 0)
if (r < 0 || k < 2) {
if (r >= 0 && k < 2)
r = -ERANGE;
return log_error_errno(r, "Invalid struct/dict entry signature: %m");
}
{
char s[k-1];
+6
View File
@@ -2027,6 +2027,8 @@ _public_ int sd_bus_message_appendv(
r = signature_element_length(t, &k);
if (r < 0)
return r;
if (k < 2)
return -ERANGE;
{
char s[k - 1];
@@ -3470,6 +3472,8 @@ _public_ int sd_bus_message_readv(
r = signature_element_length(t, &k);
if (r < 0)
return r;
if (k < 2)
return -ERANGE;
{
char s[k - 1];
@@ -3650,6 +3654,8 @@ _public_ int sd_bus_message_skip(sd_bus_message *m, const char *types) {
r = signature_element_length(types, &k);
if (r < 0)
return r;
if (k < 2)
return -ERANGE;
{
char s[k-1];