lib/idmapping.c: get_map_ranges(): Don't exit() from a library function

Fixes: ff2baed5db ("idmapping: add more checks for overflow")
Link: <https://github.com/shadow-maint/shadow/commit/ff2baed5dbf81e8967b805889f565fedb48600df#r136635300>
Reported-by: Alejandro Colomar <alx@kernel.org>
Suggested-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-01-16 02:27:56 +01:00
committed by Serge Hallyn
parent c46c6a6e5a
commit b73c78581c
+4 -10
View File
@@ -46,25 +46,21 @@ get_map_ranges(int ranges, int argc, char **argv)
if (!mappings) {
fprintf(log_get_logfd(), _( "%s: Memory allocation failure\n"),
log_get_progname());
exit(EXIT_FAILURE);
return NULL;
}
/* Gather up the ranges from the command line */
m = mappings;
for (int i = 0; i < ranges * 3; i+=3, m++) {
if (a2ul(&m->upper, argv[i + 0], NULL, 0, 0, UINT_MAX) == -1) {
if (errno == ERANGE) {
if (errno == ERANGE)
fprintf(log_get_logfd(), _( "%s: subuid overflow detected.\n"), log_get_progname());
exit(EXIT_FAILURE);
}
free(mappings);
return NULL;
}
if (a2ul(&m->lower, argv[i + 1], NULL, 0, 0, UINT_MAX) == -1) {
if (errno == ERANGE) {
if (errno == ERANGE)
fprintf(log_get_logfd(), _( "%s: subuid overflow detected.\n"), log_get_progname());
exit(EXIT_FAILURE);
}
free(mappings);
return NULL;
}
@@ -73,10 +69,8 @@ get_map_ranges(int ranges, int argc, char **argv)
MIN(UINT_MAX, ULONG_MAX - 1) - m->upper))
== -1)
{
if (errno == ERANGE) {
if (errno == ERANGE)
fprintf(log_get_logfd(), _( "%s: subuid overflow detected.\n"), log_get_progname());
exit(EXIT_FAILURE);
}
free(mappings);
return NULL;
}