selinux: set missing errno in failure branch

Set errno in open_file() if rolling_append(), which does not set errno,
failed, since transitive callers might rely on it.

Reported-by: clang-analyzer
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
Christian Göttsche 2024-10-18 17:13:00 +02:00 committed by James Carter
parent c76b273855
commit cecbff935b
1 changed files with 3 additions and 1 deletions

View File

@ -563,8 +563,10 @@ static FILE *open_file(const char *path, const char *suffix,
/* This handles the case if suffix is null */
path = rolling_append(stack_path, fdetails[i].suffix,
sizeof(stack_path));
if (!path)
if (!path) {
errno = ENOMEM;
return NULL;
}
rc = stat(path, &fdetails[i].sb);
if (rc)