cursor: Ignore invalid cursor files

The header offset must not be smaller than file header length.
Ignore such invalid files.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
This commit is contained in:
Tobias Stoeckmann 2024-09-12 22:18:30 +02:00 committed by Simon Ser
parent 5c2f31d8d6
commit 2978fd701a

View file

@ -259,6 +259,8 @@ xcursor_read_file_header(FILE *file)
return NULL; return NULL;
if (!xcursor_read_uint(file, &head.ntoc)) if (!xcursor_read_uint(file, &head.ntoc))
return NULL; return NULL;
if (head.header < XCURSOR_FILE_HEADER_LEN)
return NULL;
skip = head.header - XCURSOR_FILE_HEADER_LEN; skip = head.header - XCURSOR_FILE_HEADER_LEN;
if (skip) if (skip)
if (fseek(file, skip, SEEK_CUR) == EOF) if (fseek(file, skip, SEEK_CUR) == EOF)