mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
Do not allow nullable arrays, which were not correctly implemented
Nullable arrays, which are not used anywhere, were marshalled the same way as an empty non-null array. The demarshalling logic did not recognize anything as a null array. Given this, it seems better to just explicitly not support it. Fixes https://gitlab.freedesktop.org/wayland/wayland/-/issues/306. Signed-off-by: Ian Douglas Scott <idscott@system76.com>
This commit is contained in:
parent
7cdc20cee6
commit
13b05c9ed1
4 changed files with 4 additions and 17 deletions
|
|
@ -636,7 +636,7 @@ wl_closure_marshal(struct wl_object *sender, uint32_t opcode,
|
|||
closure->args[i].n = object ? object->id : 0;
|
||||
break;
|
||||
case 'a':
|
||||
if (!arg.nullable && args[i].a == NULL)
|
||||
if (args[i].a == NULL)
|
||||
goto err_null;
|
||||
break;
|
||||
case 'h':
|
||||
|
|
|
|||
|
|
@ -411,11 +411,10 @@ static bool
|
|||
is_nullable_type(struct arg *arg)
|
||||
{
|
||||
switch (arg->type) {
|
||||
/* Strings, objects, and arrays are possibly nullable */
|
||||
/* Strings and objects are possibly nullable */
|
||||
case STRING:
|
||||
case OBJECT:
|
||||
case NEW_ID:
|
||||
case ARRAY:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -305,7 +305,6 @@ TEST(connection_marshal_nullables)
|
|||
{
|
||||
struct marshal_data data;
|
||||
struct wl_object object;
|
||||
struct wl_array array;
|
||||
const char text[] = "curry";
|
||||
|
||||
setup_marshal_data(&data);
|
||||
|
|
@ -317,9 +316,6 @@ TEST(connection_marshal_nullables)
|
|||
marshal(&data, "?o", 12, NULL);
|
||||
assert(data.buffer[2] == 0);
|
||||
|
||||
marshal(&data, "?a", 12, NULL);
|
||||
assert(data.buffer[2] == 0);
|
||||
|
||||
marshal(&data, "?s", 12, NULL);
|
||||
assert(data.buffer[2] == 0);
|
||||
|
||||
|
|
@ -327,12 +323,6 @@ TEST(connection_marshal_nullables)
|
|||
marshal(&data, "?o", 12, &object);
|
||||
assert(data.buffer[2] == object.id);
|
||||
|
||||
array.data = (void *) text;
|
||||
array.size = sizeof text;
|
||||
marshal(&data, "?a", 20, &array);
|
||||
assert(data.buffer[2] == array.size);
|
||||
assert(memcmp(&data.buffer[3], text, array.size) == 0);
|
||||
|
||||
marshal(&data, "?s", 20, text);
|
||||
assert(data.buffer[2] == sizeof text);
|
||||
assert(strcmp((char *) &data.buffer[3], text) == 0);
|
||||
|
|
|
|||
|
|
@ -64,8 +64,7 @@ TEST(message_count_arrays)
|
|||
{ "multiple", "aaiufaasonhaa", NULL },
|
||||
{ "leading_version", "2aaiufaasonhaa", NULL },
|
||||
{ "among_nullables", "iufsa?oa?nah", NULL },
|
||||
{ "nullable", "?aiufs?a?onh?a", NULL },
|
||||
{ "all_mixed", "2?aiufas?oa?na", NULL },
|
||||
{ "all_mixed", "2aiufas?oa?na", NULL },
|
||||
};
|
||||
const struct {
|
||||
const struct wl_message *message;
|
||||
|
|
@ -81,8 +80,7 @@ TEST(message_count_arrays)
|
|||
{ &fake_messages[5], 6 },
|
||||
{ &fake_messages[6], 6 },
|
||||
{ &fake_messages[7], 3 },
|
||||
{ &fake_messages[8], 3 },
|
||||
{ &fake_messages[9], 4 },
|
||||
{ &fake_messages[8], 4 },
|
||||
};
|
||||
|
||||
for (i = 0; i < ARRAY_LENGTH(messages); ++i) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue