You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2012/10/31 14:43:45 UTC

svn commit: r1404138 - /subversion/trunk/subversion/libsvn_subr/named_atomic.c

Author: stefan2
Date: Wed Oct 31 13:43:45 2012
New Revision: 1404138

URL: http://svn.apache.org/viewvc?rev=1404138&view=rev
Log:
Make sure that the data file to be mapped into memory is at least as
large as the data region we want to map.

* subversion/libsvn_subr/named_atomic.c
  (svn_atomic_namespace__create): ensure file size before using

Modified:
    subversion/trunk/subversion/libsvn_subr/named_atomic.c

Modified: subversion/trunk/subversion/libsvn_subr/named_atomic.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/named_atomic.c?rev=1404138&r1=1404137&r2=1404138&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/named_atomic.c (original)
+++ subversion/trunk/subversion/libsvn_subr/named_atomic.c Wed Oct 31 13:43:45 2012
@@ -389,7 +389,7 @@ svn_atomic_namespace__create(svn_atomic_
   apr_file_t *file;
   apr_mmap_t *mmap;
   const char *shm_name, *lock_name;
-  svn_node_kind_t kind;
+  apr_finfo_t finfo;
 
   apr_pool_t *subpool = svn_pool_create(result_pool);
 
@@ -426,14 +426,14 @@ svn_atomic_namespace__create(svn_atomic_
   /* First, make sure that the underlying file exists.  If it doesn't
    * exist, create one and initialize its content.
    */
-  err = svn_io_check_path(shm_name, &kind, subpool);
-  if (!err && kind != svn_node_file)
+  err = svn_io_file_open(&file, shm_name,
+                          APR_READ | APR_WRITE | APR_CREATE,
+                          APR_OS_DEFAULT,
+                          result_pool);
+  if (!err)
     {
-      err = svn_io_file_open(&file, shm_name,
-                             APR_READ | APR_WRITE | APR_CREATE,
-                             APR_OS_DEFAULT,
-                             result_pool);
-      if (!err)
+      err = svn_io_stat(&finfo, shm_name, APR_FINFO_SIZE, subpool);
+      if (!err && finfo.size < sizeof(struct shared_data_t))
         {
            /* Zero all counters, values and names.
             */
@@ -444,12 +444,6 @@ svn_atomic_namespace__create(svn_atomic_
                                         subpool);
         }
     }
-  else
-    {
-      err = svn_io_file_open(&file, shm_name,
-                             APR_READ | APR_WRITE, APR_OS_DEFAULT,
-                             result_pool);
-    }
 
   /* Now, map it into memory.
    */