]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/2.2.8-strip-path.patch
db75b85b698b2115703bfb9d3a054f00816e7256
[bacula/bacula] / bacula / patches / 2.2.8-strip-path.patch
1
2  This patch should fix bug #1047 -- heap corruption when using
3  strippath on certain directories.
4
5  Apply it to 2.2.8 (probably prior versions) with:
6
7  cd <bacula-source>
8  patch -p0 <2.2.8-strip-path.patch
9  ./configure <your-options>
10  make 
11  ...
12  make install
13
14
15 Index: src/filed/backup.c
16 ===================================================================
17 --- src/filed/backup.c  (revision 6390)
18 +++ src/filed/backup.c  (revision 6391)
19 @@ -1146,20 +1146,21 @@
20     /* 
21      * Strip path.  If it doesn't succeed put it back.  If
22      *  it does, and there is a different link string,
23 -    *  attempt to strip the link. If it fails, but them
24 +    *  attempt to strip the link. If it fails, back them
25      *  both back.
26 +    * Don't strip symlinks.
27      * I.e. if either stripping fails don't strip anything.
28      */
29     if (do_strip(ff_pkt->strip_path, ff_pkt->fname)) {
30 -      if (ff_pkt->fname != ff_pkt->link) {
31 +      if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) {
32           pm_strcpy(ff_pkt->link_save, ff_pkt->link);
33           if (!do_strip(ff_pkt->strip_path, ff_pkt->link)) {
34 -            strcpy(ff_pkt->link, ff_pkt->link_save);
35 -            strcpy(ff_pkt->fname, ff_pkt->fname_save);
36 +            pm_strcpy(ff_pkt->link, ff_pkt->link_save);
37 +            pm_strcpy(ff_pkt->fname, ff_pkt->fname_save);
38           }
39        }
40     } else {
41 -      strcpy(ff_pkt->fname, ff_pkt->fname_save);
42 +      pm_strcpy(ff_pkt->fname, ff_pkt->fname_save);
43     } 
44     Dmsg2(200, "fname=%s stripped=%s\n", ff_pkt->fname_save, ff_pkt->fname);
45  }
46 @@ -1169,8 +1170,8 @@
47     if (!(ff_pkt->flags & FO_STRIPPATH) || ff_pkt->strip_path <= 0) {
48        return;
49     }
50 -   strcpy(ff_pkt->fname, ff_pkt->fname_save);
51 -   if (ff_pkt->fname != ff_pkt->link) {
52 -      strcpy(ff_pkt->link, ff_pkt->link_save);
53 +   pm_strcpy(ff_pkt->fname, ff_pkt->fname_save);
54 +   if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) {
55 +      pm_strcpy(ff_pkt->link, ff_pkt->link_save);
56     }
57  }