Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/gen Avoid infinite loop if pathname is longer than ...



details:   https://anonhg.NetBSD.org/src/rev/f3bc0b50d699
branches:  trunk
changeset: 474566:f3bc0b50d699
user:      sommerfeld <sommerfeld%NetBSD.org@localhost>
date:      Sun Jul 11 18:01:46 1999 +0000

description:
Avoid infinite loop if pathname is longer than the maximum the kernel
is willing to return from getcwd().
(this can only happen in -current).

diffstat:

 lib/libc/gen/getcwd.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r 6799087bd31c -r f3bc0b50d699 lib/libc/gen/getcwd.c
--- a/lib/libc/gen/getcwd.c     Sun Jul 11 17:47:21 1999 +0000
+++ b/lib/libc/gen/getcwd.c     Sun Jul 11 18:01:46 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getcwd.c,v 1.19 1999/06/11 15:38:40 christos Exp $     */
+/*     $NetBSD: getcwd.c,v 1.20 1999/07/11 18:01:46 sommerfeld Exp $   */
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)getcwd.c   8.5 (Berkeley) 2/7/95";
 #else
-__RCSID("$NetBSD: getcwd.c,v 1.19 1999/06/11 15:38:40 christos Exp $");
+__RCSID("$NetBSD: getcwd.c,v 1.20 1999/07/11 18:01:46 sommerfeld Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -412,6 +412,8 @@
        for (;;) {
                len = __getcwd(pt, bufsize);
                if ((len < 0) && (size == 0) && (errno == ERANGE)) {
+                       if (ptsize > (MAXPATHLEN*4))
+                               return NULL;
                        if ((pt = realloc(pt, ptsize *= 2)) == NULL)
                                return NULL;
                        bufsize = ptsize;



Home | Main Index | Thread Index | Old Index