@matheusbsbs / matheus-bagliano / commits / cb2cada6da
Fork 0

Catch empty pathnames in trees during fsck

Released versions of fast-import have been able to create a tree that contains files or subtrees that contain no name. Unfortunately these trees aren't valid, but people may have actually tried to create them due to bugs in import-tars.perl or their own fast-import frontend. We now look for this unusual condition and warn the user if at least one of their tree objects contains the problem. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Shawn O. Pearce committed Apr 28, 2007 at 20:29 UTC cb2cada6da9d71604fd09efbff47cddbea453e1e
1 file changed +6
builtin-fsck.c
+6
@@ -218,6 +218,7 @@ static int fsck_tree(struct tree *item)
218 {
219 int retval;
220 int has_full_path = 0;
221 + int has_empty_name = 0;
222 int has_zero_pad = 0;
223 int has_bad_modes = 0;
224 int has_dup_entries = 0;
@@ -241,6 +242,8 @@ static int fsck_tree(struct tree *item)
242
243 if (strchr(name, '/'))
244 has_full_path = 1;
245 + if (!*name)
246 + has_empty_name = 1;
247 has_zero_pad |= *(char *)desc.buffer == '0';
248 update_tree_entry(&desc);
249
@@ -289,6 +292,9 @@ static int fsck_tree(struct tree *item)
292 if (has_full_path) {
293 objwarning(&item->object, "contains full pathnames");
294 }
295 + if (has_empty_name) {
296 + objwarning(&item->object, "contains empty pathname");
297 + }
298 if (has_zero_pad) {
299 objwarning(&item->object, "contains zero-padded file modes");
300 }