Avoid out of bounds access if path is "/". From Martin <openbsd () academicsolutions ! ch> with tweaks by me. ok stsp
diff --git a/Makefile b/Makefile
old mode 100640
new mode 100644
diff --git a/lib/path.c b/lib/path.c
index fefe29c..612f8ea 100644
--- a/lib/path.c
+++ b/lib/path.c
@@ -391,9 +391,10 @@ got_path_basename(char **s, const char *path)
void
got_path_strip_trailing_slashes(char *path)
{
- int x;
+ size_t x;
- while (path[x = strlen(path) - 1] == '/')
+ x = strlen(path);
+ while (x-- > 0 && path[x] == '/')
path[x] = '\0';
}