]> git.sur5r.net Git - bacula/bacula/commitdiff
Correct buffer corruption with long directory names
authorKern Sibbald <kern@sibbald.com>
Thu, 19 Jun 2003 08:49:17 +0000 (08:49 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 19 Jun 2003 08:49:17 +0000 (08:49 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@592 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/ReleaseNotes
bacula/kernstodo
bacula/src/findlib/find.c
bacula/src/findlib/find_one.c

index 186246c342b890d34230415e8b9536f1f21e5bab..6aa7421e133a6b45ab194039c02f2b8285bd26fa 100644 (file)
@@ -1,7 +1,7 @@
 
           Release Notes for Bacula 1.31
 
-  Bacula code: Total files = 250 Total lines = 74,253 (*.h *.c *.in)
+  Bacula code: Total files = 250 Total lines = 74,359 (*.h *.c *.in)
 
 Major Changes this Release:
 - The database format has changed. Please see below.
@@ -16,6 +16,7 @@ Major Changes this Release:
 - Added readline to depkgs (removed from depkgs1) and fixed configuration if
   it is not installed in your system libraries.
 - Implemented generalized tape label formats including counter variables.
+- Implement multiple simultaneous jobs.
 
 
 Other Changes this Release:
index 8e1230ed5a1afa74453ffcdf0131ef28af0a16a6..0b93b60f6cec23bd8aea09855eb4b256015f9b29 100644 (file)
@@ -28,7 +28,6 @@ Testing to do: (painful)
 - Test multiple simultaneous Volumes
 - Test of last block is correct in JobMedia when splitting file 
   over two volumes.
-
 - Figure out how to use ssh or stunnel to protect Bacula communications.
 
 For 1.31 release:
@@ -984,4 +983,5 @@ Done: (see kernsdone for more)
 - Add restore to specific date.
 - Instrument use_count on DEVICE packets and ensure that the device is
   being close()ed at the appropriate time.
+- Test long path names (>64 chars) in Windows -- crashes FD?
 
index 348d9653988a6b3eb93ae3019aa691435cc16c42..edd6e9e4ef3c1d23e6553cb2e50a8d33f9450153 100644 (file)
@@ -45,7 +45,7 @@ FF_PKT *init_find_files()
 {
   FF_PKT *ff;   
 
-  ff = (FF_PKT *) bmalloc(sizeof(FF_PKT));
+  ff = (FF_PKT *)bmalloc(sizeof(FF_PKT));
   memset(ff, 0, sizeof(FF_PKT));
 
   ff->sys_fname = get_pool_memory(PM_FNAME);
index 35f5624023a4a780533fad4a1aa92bc4104fc560..3fbce57e449123bbd6118a13347c9417cc492f3d 100755 (executable)
@@ -47,6 +47,14 @@ struct f_link {
     char name[1];                    /* The name */
 };
 
+static void free_dir_ff_pkt(FF_PKT *dir_ff_pkt)
+{
+   free(dir_ff_pkt->fname);
+   free(dir_ff_pkt->link);
+   free_pool_memory(dir_ff_pkt->sys_fname);
+   free(dir_ff_pkt);
+}
+
 /*
  * Find a single file.                       
  * handle_file is the callback for handling the file.
@@ -235,11 +243,20 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
       } else {
         ff_pkt->type = FT_DIR;
       }
-      FF_PKT *dir_ff_pkt;
-      dir_ff_pkt = (FF_PKT *)bmalloc(sizeof(FF_PKT));
+
+      /*
+       * Create a temporary ff packet for this directory
+       *   entry, and defer handling the directory until
+       *   we have recursed into it.  This saves the
+       *   directory after all files have been processed, and
+       *   during the restore, the directory permissions will
+       *   be reset after all the files have been restored.
+       */
+      FF_PKT *dir_ff_pkt = (FF_PKT *)bmalloc(sizeof(FF_PKT));
       memcpy(dir_ff_pkt, ff_pkt, sizeof(FF_PKT));
       dir_ff_pkt->fname = bstrdup(ff_pkt->fname);
       dir_ff_pkt->link = bstrdup(ff_pkt->link);
+      dir_ff_pkt->sys_fname = get_pool_memory(PM_FNAME);
        
       ff_pkt->link = ff_pkt->fname;     /* reset "link" */
 
@@ -255,9 +272,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
            ff_pkt->linked->FileIndex = ff_pkt->FileIndex;
         }
         free(link);
-        free(dir_ff_pkt->fname);
-        free(dir_ff_pkt->link);
-        free(dir_ff_pkt);
+        free_dir_ff_pkt(dir_ff_pkt);
         return rtn_stat;
       }
 
@@ -274,13 +289,12 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
            ff_pkt->linked->FileIndex = ff_pkt->FileIndex;
         }
         free(link);
-        free(dir_ff_pkt->fname);
-        free(dir_ff_pkt->link);
-        free(dir_ff_pkt);
+        free_dir_ff_pkt(dir_ff_pkt);
         return rtn_stat;
       }
       /* 
-       * Open directory for reading files within 
+       * Decend into or "recurse" into the directory to read
+       *   all the files in it.
        */
       errno = 0;
       if ((directory = opendir(fname)) == NULL) {
@@ -291,9 +305,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
            ff_pkt->linked->FileIndex = ff_pkt->FileIndex;
         }
         free(link);
-        free(dir_ff_pkt->fname);
-        free(dir_ff_pkt->link);
-        free(dir_ff_pkt);
+        free_dir_ff_pkt(dir_ff_pkt);
         return rtn_stat;
       }
 
@@ -351,9 +363,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt),
       if (ff_pkt->linked) {
         ff_pkt->linked->FileIndex = dir_ff_pkt->FileIndex;
       }
-      free(dir_ff_pkt->fname);
-      free(dir_ff_pkt->link);
-      free(dir_ff_pkt);
+      free_dir_ff_pkt(dir_ff_pkt);
 
       if (ff_pkt->atime_preserve) {
         utime(fname, &restore_times);