`convertPathnameToDirName` fails to strip trailing slashes due to off‑by‑one index
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Search the zstd C sources for convertPathnameToDirName() and inspect the trailing-slash handling described in the issue. Reproduce it with the "foo/bar/" input, then run the relevant existing test or add a focused check to confirm the returned pathname is "foo/bar".
Written by the indexing model from the issue text.
Description
Describe the bug
In convertPathnameToDirName(), the code attempts to remove trailing / characters with:
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
- Call
convertPathnameToDirName("foo/bar/"). - Expect
"foo/bar", but function returns"foo/bar/".
- Dominant language
- C
- Stars
- 27.9k
- Forks
- 2.6k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 8
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from facebook/zstd
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Similar issues
-
level/task module/gcp type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
docs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
P3 sonic-vpp
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sonic-net/sonic-buildimage#29662 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
spack/spack-packages#6586 ·
-
category:port-update
Difficulty 2/5 1-3 hours Newbie friendliness 72/100