Unverified Commit 14c1904b by 2xsec Committed by Christian Brauner

fix tainted int loop bound issue

Signed-off-by: 's avatar2xsec <dh48.jeong@samsung.com>
parent 4e194cee
......@@ -310,7 +310,7 @@ int lxc_caps_init(void)
return 0;
}
static int _real_caps_last_cap(void)
static long int _real_caps_last_cap(void)
{
int fd, result = -1;
......@@ -354,10 +354,13 @@ static int _real_caps_last_cap(void)
int lxc_caps_last_cap(void)
{
static int last_cap = -1;
static long int last_cap = -1;
if (last_cap < 0)
if (last_cap < 0) {
last_cap = _real_caps_last_cap();
if (last_cap < 0 || last_cap > INT_MAX)
last_cap = -1;
}
return last_cap;
}
......
......@@ -397,7 +397,7 @@ static bool cg_legacy_filter_and_set_cpus(char *path, bool am_initialized)
/* Get maximum number of cpus found in possible cpuset. */
maxposs = get_max_cpus(posscpus);
if (maxposs < 0)
if (maxposs < 0 || maxposs >= INT_MAX - 1)
goto on_error;
if (!file_exists(__ISOL_CPUS)) {
......@@ -442,7 +442,7 @@ static bool cg_legacy_filter_and_set_cpus(char *path, bool am_initialized)
/* Get maximum number of cpus found in isolated cpuset. */
maxisol = get_max_cpus(isolcpus);
if (maxisol < 0)
if (maxisol < 0 || maxisol >= INT_MAX - 1)
goto on_error;
if (maxposs < maxisol)
......
......@@ -1806,7 +1806,7 @@ static bool cg_filter_and_set_cpus(char *path, bool am_initialized)
/* Get maximum number of cpus found in possible cpuset. */
maxposs = cg_get_max_cpus(posscpus);
if (maxposs < 0)
if (maxposs < 0 || maxposs >= INT_MAX - 1)
goto on_error;
if (!file_exists(__ISOL_CPUS)) {
......@@ -1856,7 +1856,7 @@ static bool cg_filter_and_set_cpus(char *path, bool am_initialized)
/* Get maximum number of cpus found in isolated cpuset. */
maxisol = cg_get_max_cpus(isolcpus);
if (maxisol < 0)
if (maxisol < 0 || maxisol >= INT_MAX - 1)
goto on_error;
if (maxposs < maxisol)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment