if ((Int)ARG3 >= 0)
PRE_MEM_READ( "readv(vector)", ARG2, ARG3 * sizeof(struct vki_iovec) );
- if (ARG2 != 0) {
- /* ToDo: don't do any of the following if the vector is invalid */
+ if (ML_(safe_to_deref)((const void*)ARG2, ARG3*sizeof(struct vki_iovec *))) {
vec = (struct vki_iovec *)(Addr)ARG2;
for (i = 0; i < (Int)ARG3; i++)
PRE_MEM_WRITE( "readv(vector[...])",
if ((Int)ARG3 >= 0)
PRE_MEM_READ( "writev(vector)",
ARG2, ARG3 * sizeof(struct vki_iovec) );
- if (ARG2 != 0) {
- /* ToDo: don't do any of the following if the vector is invalid */
+
+ if (ML_(safe_to_deref)((const void*)ARG2, ARG3*sizeof(struct vki_iovec *))) {
vec = (struct vki_iovec *)(Addr)ARG2;
for (i = 0; i < (Int)ARG3; i++)
PRE_MEM_READ( "writev(vector[...])",
else
fprintf(stderr, "Error readv returned a positive value\n");
+ // test with totally bogus iovec pointer
+ // see bugz 424012
+ if (writev(fd, (const struct iovec *)1, 1) < 0) {
+ if (errno == EFAULT)
+ fprintf(stderr, "Received EFAULT as expected\n");
+ else
+ fprintf(stderr, "Expected EFAULT, got %d\n", errno);
+ }
+ else
+ fprintf(stderr, "Error writev returned a positive value\n");
+
+ if (readv(fd, (const struct iovec *)1, 1) < 0) {
+ if (errno == EFAULT)
+ fprintf(stderr, "Received EFAULT as expected\n");
+ else
+ fprintf(stderr, "Expected EFAULT, got %d\n", errno);
+ }
+ else
+ fprintf(stderr, "Error readv returned a positive value\n");
+
unlink(f_name);
return 0;
Received EFAULT as expected
Received EINVAL as expected
Received EINVAL as expected
+Syscall param writev(vector) points to unaddressable byte(s)
+ ...
+ by 0x........: main (writev1.c:87)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Received EFAULT as expected
+Syscall param readv(vector) points to unaddressable byte(s)
+ ...
+ by 0x........: main (writev1.c:96)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Received EFAULT as expected