diff options
author | Marius Vlad <marius.vlad@collabora.com> | 2022-09-21 10:54:09 +0300 |
---|---|---|
committer | Marius Vlad <marius.vlad@collabora.com> | 2022-11-21 13:55:20 +0200 |
commit | 715eb67cd8cc80dd7e828624493e0c6edf936d75 (patch) | |
tree | 34528bd2677939a517c1e8385e2c5b19490f449f | |
parent | 0da83cc1d82e49119214fdcfd1bc164de709771c (diff) |
backend-rdp/rdpclip: Avoid printing negative index
As clipboard_find_supported_format_by_mime_type() can return -1 if it
can't find out an index avoid trying to print outside of the array.
Fixes the following warnings triggered when enabling FORTIFY_SOURCE
combined with optimizations (-O)
../libweston/backend-rdp/rdpclip.c:1114:17: error: array subscript -1 is below array bounds of ‘uint32_t[5]’ {aka ‘unsigned int[5]’} [-Werror=array-bounds]
1114 | weston_log("RDP %s (%p:%s) specified format \"%s\" index:%d formatId:%d is not supported by client\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1115 | __func__, source, clipboard_data_source_state_to_string(source),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1116 | mime_type, index, source->client_format_id_table[index]);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../libweston/backend-rdp/rdpclip.c:131:18: note: while referencing ‘client_format_id_table’
131 | uint32_t client_format_id_table[RDP_NUM_CLIPBOARD_FORMATS];
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
(cherry picked from commit 9455ad7c7c07fdb8218330f449c97be73f695742)
-rw-r--r-- | libweston/backend-rdp/rdpclip.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libweston/backend-rdp/rdpclip.c b/libweston/backend-rdp/rdpclip.c index f92bf7a0..e08f4ca2 100644 --- a/libweston/backend-rdp/rdpclip.c +++ b/libweston/backend-rdp/rdpclip.c @@ -1111,9 +1111,9 @@ clipboard_data_source_send(struct weston_data_source *base, } } else { source->state = RDP_CLIPBOARD_SOURCE_FAILED; - weston_log("RDP %s (%p:%s) specified format \"%s\" index:%d formatId:%d is not supported by client\n", + weston_log("RDP %s (%p:%s) specified format \"%s\" index:%d is not supported by client\n", __func__, source, clipboard_data_source_state_to_string(source), - mime_type, index, source->client_format_id_table[index]); + mime_type, index); goto error_return_close_fd; } |