Skip to content

Commit

Permalink
Fix extra trailing '\0' char in uvwasi_path_readlink (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn authored May 2, 2024
1 parent 81ac54a commit 38d124c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/uvwasi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2199,7 +2199,7 @@ uvwasi_errno_t uvwasi_path_readlink(uvwasi_t* uvwasi,

memcpy(buf, req.ptr, len);
buf[len] = '\0';
*bufused = len + 1;
*bufused = len;
uv_fs_req_cleanup(&req);
return UVWASI_ESUCCESS;
}
Expand Down
4 changes: 2 additions & 2 deletions test/test-symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int main(void) {
strlen(path) + 1,
&bufused);
assert(err == 0);
assert(bufused == strlen(path) + 1);
assert(bufused == strlen(path));
assert(strcmp(buf, path) == 0);

err = uvwasi_path_unlink_file(&uvwasi, 3, linkname, strlen(linkname));
Expand All @@ -79,7 +79,7 @@ int main(void) {
strlen(truncated_path) + 1,
&bufused);
assert(err == 0);
assert(bufused == strlen(truncated_path) + 1);
assert(bufused == strlen(truncated_path));
assert(strcmp(buf, truncated_path) == 0);

err = uvwasi_path_unlink_file(&uvwasi, 3, truncated_linkname, strlen(truncated_linkname));
Expand Down

0 comments on commit 38d124c

Please sign in to comment.