(spotted by Florian Krohm/IBM's BEAM checker)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14559
arg1 &= ~_RLIMIT_POSIX_FLAG;
#endif
- if (ARG2 &&
- ((struct vki_rlimit *)ARG2)->rlim_cur > ((struct vki_rlimit *)ARG2)->rlim_max) {
+ if (!VG_(am_is_valid_for_client)(ARG2, sizeof(struct vki_rlimit),
+ VKI_PROT_READ)) {
+ SET_STATUS_Failure( VKI_EFAULT );
+ }
+ else if (((struct vki_rlimit *)ARG2)->rlim_cur
+ > ((struct vki_rlimit *)ARG2)->rlim_max) {
SET_STATUS_Failure( VKI_EINVAL );
}
else if (arg1 == VKI_RLIMIT_NOFILE) {
{
perror("open");
}
+
+ if (setrlimit(RLIMIT_NOFILE, NULL) != -1 || errno != EFAULT)
+ {
+ fprintf(stderr, "setrlimit non addressable arg2 must set errno=EFAULT\n");
+ exit(1);
+ }
exit(0);
}