mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-08-08 09:21:48 +08:00
Suppress Coverity Scan false positive
** CID 646042: Insecure data handling (INTEGER_OVERFLOW) /src/isolate.c: 59 in compute_worker_data_limit() Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
This commit is contained in:
+9
-2
@@ -45,6 +45,7 @@ static rlim_t compute_worker_data_limit(unsigned headroom_kb)
|
|||||||
/* statm: size resident shared text lib data dt (all in pages) */
|
/* statm: size resident shared text lib data dt (all in pages) */
|
||||||
unsigned long size, resident, shared, text, lib, data;
|
unsigned long size, resident, shared, text, lib, data;
|
||||||
int n;
|
int n;
|
||||||
|
long pagesize;
|
||||||
|
|
||||||
f = fopen("/proc/self/statm", "r");
|
f = fopen("/proc/self/statm", "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
@@ -56,8 +57,14 @@ static rlim_t compute_worker_data_limit(unsigned headroom_kb)
|
|||||||
if (n != 6)
|
if (n != 6)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (rlim_t)data * (rlim_t)sysconf(_SC_PAGESIZE) +
|
pagesize = sysconf(_SC_PAGESIZE);
|
||||||
(rlim_t)headroom_kb * 1024;
|
if (pagesize < 0)
|
||||||
|
return 0;
|
||||||
|
/* A process where data * pagesize overflows unsigned long (64-bit)
|
||||||
|
* would use more than 16 million TB of data pages!
|
||||||
|
*
|
||||||
|
* coverity[INTEGER_OVERFLOW] */
|
||||||
|
return (rlim_t)data * (rlim_t)pagesize + (rlim_t)headroom_kb * 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Apply per-worker heap cap (RLIMIT_DATA) unless explicitly disabled. */
|
/* Apply per-worker heap cap (RLIMIT_DATA) unless explicitly disabled. */
|
||||||
|
|||||||
Reference in New Issue
Block a user