]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Make the virtualise setrlimit(RLIMIT_DATA) return EPERM when an attempt
authorTom Hughes <tom@compton.nu>
Sat, 11 Sep 2004 14:19:25 +0000 (14:19 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 11 Sep 2004 14:19:25 +0000 (14:19 +0000)
is made to raise either the soft or hard limit above the current hard
limit rather than just allowing it.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2690

coregrind/vg_syscalls.c

index 14ea259c99b8d432ea7960a4a1a99e90760e59a1..9126c11ce12de0d026b59889f4ed03acf4aa1ae4 100644 (file)
@@ -4693,8 +4693,14 @@ PRE(setrlimit)
       }
    }
    else if (arg1 == VKI_RLIMIT_DATA) {
-      VG_(client_rlimit_data) = *(vki_rlimit *)arg2;
-      res = 0;
+      if (((vki_rlimit *)arg2)->rlim_cur > ((vki_rlimit *)arg2)->rlim_max ||
+          ((vki_rlimit *)arg2)->rlim_max > ((vki_rlimit *)arg2)->rlim_max) {
+         res = -VKI_EPERM;
+      }
+      else {
+         VG_(client_rlimit_data) = *(vki_rlimit *)arg2;
+         res = 0;
+      }
    }
    else if (arg1 == VKI_RLIMIT_STACK && tid == 1) {
       if (((vki_rlimit *)arg2)->rlim_cur > ((vki_rlimit *)arg2)->rlim_max ||