Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Fix PR7761: clip overly large length rather than fa...



details:   https://anonhg.NetBSD.org/src/rev/642419f2c5a1
branches:  trunk
changeset: 473791:642419f2c5a1
user:      sommerfeld <sommerfeld%NetBSD.org@localhost>
date:      Sat Jun 19 18:01:26 1999 +0000

description:
Fix PR7761: clip overly large length rather than failing

diffstat:

 sys/kern/vfs_getcwd.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r 0da71809b9d2 -r 642419f2c5a1 sys/kern/vfs_getcwd.c
--- a/sys/kern/vfs_getcwd.c     Sat Jun 19 15:46:05 1999 +0000
+++ b/sys/kern/vfs_getcwd.c     Sat Jun 19 18:01:26 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_getcwd.c,v 1.6 1999/04/30 18:43:00 thorpej Exp $ */
+/* $NetBSD: vfs_getcwd.c,v 1.7 1999/06/19 18:01:26 sommerfeld Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -481,7 +481,6 @@
                return vn_isunder(r1, r2, p2);
 }
 
-
 int sys___getcwd(p, v, retval) 
        struct proc *p;
        void   *v;
@@ -498,7 +497,9 @@
        int     len = SCARG(uap, length);
        int     lenused;
 
-       if ((len < 2) || (len > MAXPATHLEN*4))
+       if (len > MAXPATHLEN*4)
+               len = MAXPATHLEN*4;
+       else if (len < 2)
                return ERANGE;
 
        path = (char *)malloc(len, M_TEMP, M_WAITOK);



Home | Main Index | Thread Index | Old Index