From: Kern Sibbald Date: Thu, 19 Jun 2003 08:49:17 +0000 (+0000) Subject: Correct buffer corruption with long directory names X-Git-Tag: Release-1.31~64 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2e36ec6f748db57d7ed24da3a82495307b602d8a;p=bacula%2Fbacula Correct buffer corruption with long directory names git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@592 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/ReleaseNotes b/bacula/ReleaseNotes index 186246c342..6aa7421e13 100644 --- a/bacula/ReleaseNotes +++ b/bacula/ReleaseNotes @@ -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: diff --git a/bacula/kernstodo b/bacula/kernstodo index 8e1230ed5a..0b93b60f6c 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -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? diff --git a/bacula/src/findlib/find.c b/bacula/src/findlib/find.c index 348d965398..edd6e9e4ef 100644 --- a/bacula/src/findlib/find.c +++ b/bacula/src/findlib/find.c @@ -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); diff --git a/bacula/src/findlib/find_one.c b/bacula/src/findlib/find_one.c index 35f5624023..3fbce57e44 100755 --- a/bacula/src/findlib/find_one.c +++ b/bacula/src/findlib/find_one.c @@ -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);