check if the real_size is negative 41/192041/1
authorSooChan Lim <sc1.lim@samsung.com>
Mon, 29 Oct 2018 06:57:28 +0000 (15:57 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 29 Oct 2018 06:57:28 +0000 (15:57 +0900)
Change-Id: I8296ac9ed31763c5ad00ec43754eb33913dd6a2a

src/tbm_bufmgr_shm.c

index 3315b68..7de5bfb 100644 (file)
@@ -668,6 +668,14 @@ tbm_shm_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_e
        }
 
        real_size = lseek(key, 0, SEEK_END);
+       if (real_size < 0) {
+               TBM_SHM_LOG("[libtbm-shm:%d] error %s:%d Fail to allocate the bo private\n", getpid(), __FUNCTION__, __LINE__);
+               free(bo_shm);
+               if (error)
+                       *error = TBM_ERROR_INVALID_OPERATION;
+               return 0;
+       }
+
        bo_shm->pBase = mmap(NULL, real_size,
                          PROT_READ | PROT_WRITE, MAP_SHARED, key, 0);
        if (bo_shm->pBase == MAP_FAILED) {