X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=inline;f=src%2Fnames.c;h=a19afd7a20c80571ddfc440d0f4a98485f2879a2;hb=ebeb3d4f3058b7bbb92e7ea797cf938ec03ee2ed;hp=5fdc43321a2eed92af7b445fb12d005def7b1d31;hpb=1e7d274cd8125901600d2f302b9a108933b0c57a;p=chaz%2Ftar diff --git a/src/names.c b/src/names.c index 5fdc433..a19afd7 100644 --- a/src/names.c +++ b/src/names.c @@ -20,9 +20,7 @@ #include "system.h" #include -#include #include -#include #include #include "common.h" @@ -610,9 +608,11 @@ bool all_names_found (struct tar_stat_info *p) { struct name const *cursor; - size_t len = strlen (p->file_name); - if (occurrence_option == 0 || p->had_trailing_slash) + size_t len; + + if (!p->file_name || occurrence_option == 0 || p->had_trailing_slash) return false; + len = strlen (p->file_name); for (cursor = namelist; cursor; cursor = cursor->next) { if (cursor->regexp @@ -1024,9 +1024,14 @@ safer_name_suffix (char const *file_name, bool link_target) for (p = file_name + prefix_len; *p; ) { - if (p[0] == '.' && p[1] == '.' && (ISSLASH (p[2]) || !p[2])) - prefix_len = p + 2 - file_name; - + if (p[0] == '.') + { + if (p[1] == '.' && (ISSLASH (p[2]) || !p[2])) + prefix_len = p + 2 - file_name; + else if (ISSLASH (p[1])) + prefix_len = p + 1 - file_name; + } + do { char c = *p++; @@ -1071,7 +1076,7 @@ safer_name_suffix (char const *file_name, bool link_target) WARN ((0, 0, _(diagnostic[link_target]))); } - p = "."; + p = ISSLASH (file_name[strlen(file_name)-1]) ? "./" : "."; } return (char *) p;