From 11fa755f9af67d6d2edb170a2a2ca65d64ca82e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Einar=20R=C3=BCnkaru?= <einarry@smail.ee>
Date: Sun, 23 Sep 2012 16:38:45 +0300
Subject: [PATCH 2/3] Fix shm usage in guicast/bcbitmap.C

Shared memory should not be world readable.
Valid shmid can be negative, error is indicated with return value -1.
---
 guicast/bcbitmap.C |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/guicast/bcbitmap.C b/guicast/bcbitmap.C
index ca0f48c..1770492 100644
--- a/guicast/bcbitmap.C
+++ b/guicast/bcbitmap.C
@@ -171,8 +171,8 @@ int BC_Bitmap::allocate_data()
 // Create the shared memory
 				shm_info.shmid = shmget(IPC_PRIVATE, 
 					xv_image[0]->data_size * ring_buffers + 4, 
-					IPC_CREAT | 0777);
-				if(shm_info.shmid < 0) perror("BC_Bitmap::allocate_data shmget");
+					IPC_CREAT | 0600);
+				if(shm_info.shmid == -1) perror("BC_Bitmap::allocate_data shmget");
 				data[0] = (unsigned char *)shmat(shm_info.shmid, NULL, 0);
 // setting ximage->data stops BadValue
 				xv_image[0]->data = shm_info.shmaddr = (char*)data[0];
@@ -226,8 +226,8 @@ int BC_Bitmap::allocate_data()
 // Create shared memory
 				shm_info.shmid = shmget(IPC_PRIVATE, 
 					h * ximage[0]->bytes_per_line * ring_buffers + 4, 
-					IPC_CREAT | 0777);
-				if(shm_info.shmid < 0) 
+					IPC_CREAT | 0600);
+				if(shm_info.shmid == -1)
 					perror("BC_Bitmap::allocate_data shmget");
 				data[0] = (unsigned char *)shmat(shm_info.shmid, NULL, 0);
 				ximage[0]->data = shm_info.shmaddr = (char*)data[0];  // setting ximage->data stops BadValue
-- 
1.7.0.4

