The ".." removal logic was looping on file/dir names starting with "..",
reported by hg42 on github.
diff --git a/tests/tar.test b/tests/tar.test
old mode 100644
new mode 100755
index 6db3518..740e0ab
--- a/tests/tar.test
+++ b/tests/tar.test
@@ -275,6 +275,14 @@
   'hello\n' '' ''
 rm -rf one test.tar
 
+mkdir ..dotsdir
+testing "create ..dotsdir" "$TAR ..dotsdir | SUM 3" \
+  "de99091a91c74ef6b90093e9165b413670730572\n" "" ""
+
+testing "pass ..dotsdir" "$TAR ..dotsdir | LST" \
+  "drwxrwxr-x root/root 0 2009-02-13 23:31 ..dotsdir/\n" "" ""
+rmdir ..dotsdir
+
 if false
 then
 
diff --git a/toys/posix/tar.c b/toys/posix/tar.c
index bd68873..0566bb6 100644
--- a/toys/posix/tar.c
+++ b/toys/posix/tar.c
@@ -225,8 +225,12 @@
     if (!(lnk = strstr(lnk, ".."))) break;
     if (lnk == hname || lnk[-1] == '/') {
       if (!lnk[2]) goto done;
-      if (lnk[2]=='/') lnk = hname = lnk+3;
-    } else lnk+= 2;
+      if (lnk[2]=='/') {
+        lnk = hname = lnk+3;
+        continue;
+      }
+    }
+    lnk += 2;
   }
   if (!*hname) goto done;