commit 455de7fa2c4ca7bb8c24c144e14c235f8d757503 from: Theo Buehler date: Sun Jan 12 18:54:21 2020 UTC Avoid out of bounds access if path is "/". From Martin with tweaks by me. ok stsp commit - 33cbf02b9777cd078e8a37db5ae068465219301c commit + 455de7fa2c4ca7bb8c24c144e14c235f8d757503 blob - fefe29cbfdc8da1f766b44e0948c98422f901875 blob + 612f8eabe6d1cf8aefde3bc0a3817eb786a9ba74 --- lib/path.c +++ 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'; }