-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix UB in test_unistd_write_broken_link #23125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The test was failing under ASan because no null byte was being read from the file, so the strlen inside printf was running off the buffer. It just happened to work on non-ASan because wasm memory is initialized to zero.
| int src_fd = open("link_source", O_CREAT | O_WRONLY, 0777); | ||
| printf("source_fd: %d, errno: %d %s\n", src_fd, errno, strerror(errno)); | ||
| write(src_fd, "abc", 3); | ||
| write(src_fd, "abc\0", 4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems a little odd to write null byte to a text file.. but I guess its not important here.
| { | ||
| int target_fd = open("link_source", O_RDONLY); | ||
| printf("target_fd: %d, errno: %d %s\n", target_fd, errno, strerror(errno)); | ||
| char buf[10]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative here I suppose would be intialize buf on the stack with char buf[10] = { '\0' };
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I could go either way on that, do you have a preference?
|
Thanks! |
The test was failing under ASan because no null byte was being read from the file, so the strlen inside printf was running off the buffer. It just happened to work on non-ASan because wasm memory is initialized to zero.
The test was failing under ASan because no null byte was being
read from the file, so the strlen inside printf was running
off the buffer. It just happened to work on non-ASan because
wasm memory is initialized to zero.