From: David Goulet Date: Wed, 1 Oct 2014 18:57:36 +0000 (-0400) Subject: Fix: handle sysconf possible negative returned value X-Git-Tag: v2.5.1~1 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=fa061a82eb56c370974259c492a54a662c0a981d;p=lttng-tools.git Fix: handle sysconf possible negative returned value Fixes Coverity issue 1019947. Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/shm.c b/src/bin/lttng-sessiond/shm.c index 7bb52d4ee..a5caa8bb6 100644 --- a/src/bin/lttng-sessiond/shm.c +++ b/src/bin/lttng-sessiond/shm.c @@ -132,12 +132,20 @@ error: */ char *shm_ust_get_mmap(char *shm_path, int global) { - size_t mmap_size = sysconf(_SC_PAGE_SIZE); + size_t mmap_size; int wait_shm_fd, ret; char *wait_shm_mmap; + long sys_page_size; assert(shm_path); + sys_page_size = sysconf(_SC_PAGE_SIZE); + if (sys_page_size < 0) { + PERROR("sysconf PAGE_SIZE"); + goto error; + } + mmap_size = sys_page_size; + wait_shm_fd = get_wait_shm(shm_path, mmap_size, global); if (wait_shm_fd < 0) { goto error;