Skip to content
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

writev() with bad address and zero size #321

Closed
kimjs29 opened this issue May 4, 2016 · 1 comment
Closed

writev() with bad address and zero size #321

kimjs29 opened this issue May 4, 2016 · 1 comment

Comments

@kimjs29
Copy link

kimjs29 commented May 4, 2016

writev() uses struct iovec which has iov_base and iov_len members.

In Linux writev() permits bad address in iov_base in case of zero iov_len value.
In WSL writev() generates an error in this case.
iov_len must be checked against zero before iov_base should be valid.

I found this case in debugging of CMake's configure_file which calls eventually ofstream::write(buf,siz) where siz is 1024 or more.

#include <sys/uio.h> // for writev & struct iov
#include <stdio.h>   // for perror
int main()
{
    struct iovec iov = {0,0};
    if (writev(2, &iov, 1) < 0)
        perror("writev() error: ");
}
@benhillis
Copy link
Member

Thanks for reporting this, this was also reported in #238 and #272. I'm going to go ahead and close this out because it's being tracked by the other two issues.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants