OSSP CVS Repository

ossp - Check-in [2379]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2379
Date: 2002-Jul-26 15:48:38 (local)
2002-Jul-26 13:48:38 (UTC)
User:rse
Branch:
Comment: Fixed race condition in temporary file creation.

Submitted by: Sebastian Krahmer, SuSE Security

Tickets:
Inspections:
Files:
ossp-pkg/mm/ChangeLog      1.33 -> 1.34     3 inserted, 3 deleted
ossp-pkg/mm/mm_core.c      1.15 -> 1.16     4 inserted, 4 deleted

ossp-pkg/mm/ChangeLog 1.33 -> 1.34

--- ChangeLog    2002/07/26 13:40:41     1.33
+++ ChangeLog    2002/07/26 13:48:38     1.34
@@ -16,6 +16,9 @@
 
  Changes between 1.1.3 and 1.2.0 (01-Jul-2000 to 26-Jul-2002)
 
+  *) Fixed race condition in temporary file creation.
+     [Sebastian Krahmer, SuSE Security]
+
   *) Make sure that under MM_SEMT_IPCSEM (mutex implementation method is
      SysV IPC semget) the {mm,MM}_permission() also changes the owner of
      the semaphore.
@@ -25,9 +28,6 @@
      MAXPATHLEN in <sys/param.h>
      [Joe Orton <jorton@redhat.com>]
 
-  *) Fixed race condition in temporary file creation.
-     [Sebastian Krahmer, SuSE Security]
-
   *) Removed the old fbtool stuff for reporting the success/failure
      because after 3 years of existence we really know that OSSP mm
      works on every reasonable Unix flavor on this earth.


ossp-pkg/mm/mm_core.c 1.15 -> 1.16

--- mm_core.c    2002/07/26 13:34:53     1.15
+++ mm_core.c    2002/07/26 13:48:38     1.16
@@ -249,7 +249,7 @@
 
 #if defined(MM_SHMT_MMPOSX)
     shm_unlink(fnmem); /* Ok when it fails */
-    if ((fdmem = shm_open(fnmem, O_RDWR|O_CREAT, MM_CORE_FILEMODE)) == -1)
+    if ((fdmem = shm_open(fnmem, O_RDWR|O_CREAT|O_EXCL, MM_CORE_FILEMODE)) == -1)
         FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to open tempfile");
     if (ftruncate(fdmem, mm_core_mapoffset+size) == -1)
         FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to truncate tempfile");
@@ -275,7 +275,7 @@
 
 #if defined(MM_SHMT_MMFILE)
     unlink(fnmem);
-    if ((fdmem = open(fnmem, O_RDWR|O_CREAT, MM_CORE_FILEMODE)) == -1)
+    if ((fdmem = open(fnmem, O_RDWR|O_CREAT|O_EXCL, MM_CORE_FILEMODE)) == -1)
         FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to open memory file");
     if (ftruncate(fdmem, mm_core_mapoffset+size) == -1)
         FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to truncate memory file");
@@ -303,13 +303,13 @@
 
 #if defined(MM_SEMT_FLOCK)
     unlink(fnsem);
-    if ((fdsem = open(fnsem, O_RDWR|O_CREAT, MM_CORE_FILEMODE)) == -1)
+    if ((fdsem = open(fnsem, O_RDWR|O_CREAT|O_EXCL, MM_CORE_FILEMODE)) == -1)
         FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to open semaphore file");
 #endif /* MM_SEMT_FLOCK */
 
 #if defined(MM_SEMT_FCNTL)
     unlink(fnsem);
-    if ((fdsem = open(fnsem, O_RDWR|O_CREAT, MM_CORE_FILEMODE)) == -1)
+    if ((fdsem = open(fnsem, O_RDWR|O_CREAT|O_EXCL, MM_CORE_FILEMODE)) == -1)
         FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to open semaphore file");
 #endif /* MM_SEMT_FCNTL */
 

CVSTrac 2.0.1