chiark / gitweb /
dgit import: Defend against broken symlinks in ..
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 15 Jul 2017 22:15:54 +0000 (23:15 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 15 Jul 2017 22:16:02 +0000 (23:16 +0100)
Provide a special error message if lstat succeeds but lstat fails.

This is not hypothetical - currently even dgit import ../blah.dsc can
generate this situation !

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
debian/changelog
dgit

index 1d912c026b9db5964cc845ca094d80c8b100c149..784269c1721cdadaa89dfc7fd205472cc50ee4e8 100644 (file)
@@ -5,6 +5,7 @@ dgit (3.12~) unstable; urgency=medium
   * Defend against commit subject lines which would generate patches which
     look like series files, etc.  Involves adding .patch to all generated
     patch filenames.
+  * dgit import: Defend against broken symlinks in ..
 
  --
 
diff --git a/dgit b/dgit
index 51975965deb49aad24c205848e0ca5170983185b..a68bf19c943502d3f039440caa29368ab2a388d9 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -6349,7 +6349,10 @@ END
     foreach my $fi (@dfi) {
        my $f = $fi->{Filename};
        my $here = "../$f";
-       next if lstat $here;
+       if (lstat $here) {
+           next if stat $here;
+           fail "lstat $here works but stat gives $! !";
+       }
        fail "stat $here: $!" unless $! == ENOENT;
        my $there = $dscfn;
        if ($dscfn =~ m#^(?:\./+)?\.\./+#) {