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.4.3~45 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=893347c2b7464a04ef2467b89752daeb219780f4;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;