]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/tree.c
Fix get_basename() -- rewrite
[bacula/bacula] / bacula / src / lib / tree.c
index fda5b0a72ca5d5a84cd31d4e1eaccdb4cfd82db7..008e25a883632dada646717be6fd1c191ee145ad 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2002-2011 Free Software Foundation Europe e.V.
+   Copyright (C) 2002-2012 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
@@ -36,9 +36,9 @@
 #include "bacula.h"
 #include "findlib/find.h"
 
-#define PAGE_SIZE 4096
+#define B_PAGE_SIZE 4096
 #define MAX_PAGES 2400
-#define MAX_BUF_SIZE (MAX_PAGES * PAGE_SIZE)  /* approx 10MB */
+#define MAX_BUF_SIZE (MAX_PAGES * B_PAGE_SIZE)  /* approx 10MB */
 
 /* Forward referenced subroutines */
 static TREE_NODE *search_and_insert_tree_node(char *fname, int type,
@@ -409,6 +409,8 @@ TREE_NODE *tree_relcwd(char *path, TREE_ROOT *root, TREE_NODE *node)
    char *p;
    int len;
    TREE_NODE *cd;
+   char save_char;
+   int match;
 
    if (*path == 0) {
       return node;
@@ -426,6 +428,14 @@ TREE_NODE *tree_relcwd(char *path, TREE_ROOT *root, TREE_NODE *node)
           && strncmp(cd->fname, path, len) == 0) {
          break;
       }
+      /* fnmatch has no len in call so we truncate the string */
+      save_char = path[len];
+      path[len] = 0;
+      match = fnmatch(path, cd->fname, 0) == 0;
+      path[len] = save_char;
+      if (match) {
+         break;
+      }
    }
    if (!cd || (cd->type == TN_FILE && !tree_node_has_child(cd))) {
       return NULL;