`convertPathnameToDirName` fails to strip trailing slashes due to off‑by‑one index
Open
- Dominant language
- C
- Stars
- 27.9k
- Forks
- 2.6k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 8
Description
**Describe the bug**
In `convertPathnameToDirName()`, the code attempts to remove trailing `/` characters with:
```c
len = strlen(pathname);
while (pathname[len] == PATH_SEP) {
pathname[len] = '\0';
len--;
}
```
However, `strlen(pathname)` is the index of the terminating NUL. As a result `pathname[len]` is always `'\0'`, never `'/'`, so the loop never runs and trailing slashes remain.
**To Reproduce**
1. Call `convertPathnameToDirName("foo/bar/")`.
2. Expect `"foo/bar"`, but function returns `"foo/bar/"`.
Contributor guide
Assessment
This issue has not been assessed yet.