Fix: sysconf() unchecked return value
[deliverable/lttng-ust.git] / liblttng-ust / lttng-ust-comm.c
index 08e6299ce3a5bd7793e4ddf04c556e9d04e2e7f8..726a30f9bdb6ffbfef4bc5fe17d11319ffdcd434 100644 (file)
@@ -948,7 +948,12 @@ void cleanup_sock_info(struct sock_info *sock_info, int exiting)
                long page_size;
 
                page_size = sysconf(_SC_PAGE_SIZE);
-               if (page_size > 0) {
+               if (page_size <= 0) {
+                       if (!page_size) {
+                               errno = EINVAL;
+                       }
+                       PERROR("Error in sysconf(_SC_PAGE_SIZE)");
+               } else {
                        ret = munmap(sock_info->wait_shm_mmap, page_size);
                        if (ret) {
                                ERR("Error unmapping wait shm");
@@ -1130,7 +1135,11 @@ char *get_map_shm(struct sock_info *sock_info)
        char *wait_shm_mmap;
 
        page_size = sysconf(_SC_PAGE_SIZE);
-       if (page_size < 0) {
+       if (page_size <= 0) {
+               if (!page_size) {
+                       errno = EINVAL;
+               }
+               PERROR("Error in sysconf(_SC_PAGE_SIZE)");
                goto error;
        }
 
This page took 0.023623 seconds and 5 git commands to generate.