diff --git a/src/path_resolver.c b/src/path_resolver.c index deb3f60..c1bff2b 100644 --- a/src/path_resolver.c +++ b/src/path_resolver.c @@ -499,14 +499,14 @@ uvwasi_errno_t uvwasi__resolve_path(const uvwasi_t* uvwasi, link_target_len = strlen(req.ptr); uvwasi__free(uvwasi, link_target); - link_target = uvwasi__malloc(uvwasi, link_target_len + 1); + link_target = uvwasi__malloc(uvwasi, link_target_len); if (link_target == NULL) { uv_fs_req_cleanup(&req); err = UVWASI_ENOMEM; goto exit; } - memcpy(link_target, req.ptr, link_target_len + 1); + memcpy(link_target, req.ptr, link_target_len); uv_fs_req_cleanup(&req); if (1 == uvwasi__is_absolute_path(link_target, link_target_len)) { diff --git a/src/uvwasi.c b/src/uvwasi.c index 7c334a7..948c135 100644 --- a/src/uvwasi.c +++ b/src/uvwasi.c @@ -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; } diff --git a/test/test-symlink.c b/test/test-symlink.c index cae5cad..a21c500 100644 --- a/test/test-symlink.c +++ b/test/test-symlink.c @@ -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)); @@ -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));