summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTobias Weingartner <weingart@cvs.openbsd.org>1997-09-17 17:26:16 +0000
committerTobias Weingartner <weingart@cvs.openbsd.org>1997-09-17 17:26:16 +0000
commit9354a62a5f41b7c55a762422bd199bfd534f75b3 (patch)
treeadd7f3395d0af95a784adcdcc9744ce3e167f3d6 /sys
parent0fcf2372afd2a5c231e5ff939c61d213c7e9e338 (diff)
Overflow checks
Diffstat (limited to 'sys')
-rw-r--r--sys/vm/vm_unix.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/sys/vm/vm_unix.c b/sys/vm/vm_unix.c
index d974d618ce6..135815a9afe 100644
--- a/sys/vm/vm_unix.c
+++ b/sys/vm/vm_unix.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_unix.c,v 1.4 1997/07/25 06:03:11 mickey Exp $ */
+/* $OpenBSD: vm_unix.c,v 1.5 1997/09/17 17:26:15 weingart Exp $ */
/* $NetBSD: vm_unix.c,v 1.19 1996/02/10 00:08:14 christos Exp $ */
/*
@@ -74,9 +74,18 @@ sys_obreak(p, v, retval)
register int diff;
old = (vm_offset_t)vm->vm_daddr;
- new = round_page(SCARG(uap, nsize));
- if ((int)(new - old) > p->p_rlimit[RLIMIT_DATA].rlim_cur)
+ new = (vm_offset_t)SCARG(uap, nsize);
+
+ /* Check for overflow, round to page */
+ if(round_page(new) < new)
+ return(ENOMEM);
+ new = round_page(new);
+
+ /* Check limit */
+ if ((new > old) && ((new - old) > p->p_rlimit[RLIMIT_DATA].rlim_cur))
return(ENOMEM);
+
+ /* Turn the trick */
old = round_page(old + ctob(vm->vm_dsize));
diff = new - old;
if (diff > 0) {