diff options
| author | Aleksandr Mezin <mezin.alexander@gmail.com> | 2022-02-09 04:10:42 +0600 |
|---|---|---|
| committer | Simon Ser <contact@emersion.fr> | 2022-03-25 09:43:53 +0000 |
| commit | 03e8a1f84b6a15c9531db1ca8d0a25f9fcffaf25 (patch) | |
| tree | cfe255888864722d46e37474341f4bdf9521125f | |
| parent | util: always check result of wl_array_add() (diff) | |
| download | wayland-03e8a1f84b6a15c9531db1ca8d0a25f9fcffaf25.tar wayland-03e8a1f84b6a15c9531db1ca8d0a25f9fcffaf25.tar.gz wayland-03e8a1f84b6a15c9531db1ca8d0a25f9fcffaf25.tar.bz2 wayland-03e8a1f84b6a15c9531db1ca8d0a25f9fcffaf25.tar.lz wayland-03e8a1f84b6a15c9531db1ca8d0a25f9fcffaf25.tar.xz wayland-03e8a1f84b6a15c9531db1ca8d0a25f9fcffaf25.tar.zst wayland-03e8a1f84b6a15c9531db1ca8d0a25f9fcffaf25.zip | |
util: set errno in wl_map_reserve_new()
And also fix wl_connection_demarshal() to pass through that errno.
Signed-off-by: Aleksandr Mezin <mezin.alexander@gmail.com>
| -rw-r--r-- | src/connection.c | 10 | ||||
| -rw-r--r-- | src/wayland-util.c | 14 |
2 files changed, 17 insertions, 7 deletions
diff --git a/src/connection.c b/src/connection.c index a2d1b2f..3a4ab47 100644 --- a/src/connection.c +++ b/src/connection.c @@ -810,10 +810,12 @@ wl_connection_demarshal(struct wl_connection *connection, } if (wl_map_reserve_new(objects, id) < 0) { - wl_log("not a valid new object id (%u), " - "message %s(%s)\n", - id, message->name, message->signature); - errno = EINVAL; + if (errno == EINVAL) { + wl_log("not a valid new object id (%u), " + "message %s(%s)\n", id, + message->name, + message->signature); + } goto err; } diff --git a/src/wayland-util.c b/src/wayland-util.c index 68116bf..ee74bc1 100644 --- a/src/wayland-util.c +++ b/src/wayland-util.c @@ -24,6 +24,7 @@ * SOFTWARE. */ +#include <errno.h> #include <stdlib.h> #include <stdint.h> #include <stdio.h> @@ -261,13 +262,17 @@ wl_map_reserve_new(struct wl_map *map, uint32_t i) struct wl_array *entries; if (i < WL_SERVER_ID_START) { - if (map->side == WL_MAP_CLIENT_SIDE) + if (map->side == WL_MAP_CLIENT_SIDE) { + errno = EINVAL; return -1; + } entries = &map->client_entries; } else { - if (map->side == WL_MAP_SERVER_SIDE) + if (map->side == WL_MAP_SERVER_SIDE) { + errno = EINVAL; return -1; + } entries = &map->server_entries; i -= WL_SERVER_ID_START; @@ -275,8 +280,10 @@ wl_map_reserve_new(struct wl_map *map, uint32_t i) count = entries->size / sizeof *start; - if (count < i) + if (count < i) { + errno = EINVAL; return -1; + } if (count == i) { if (!wl_array_add(entries, sizeof *start)) @@ -287,6 +294,7 @@ wl_map_reserve_new(struct wl_map *map, uint32_t i) } else { start = entries->data; if (start[i].data != NULL) { + errno = EINVAL; return -1; } } |
