$NetBSD: patch-al,v 1.5 1999/03/07 16:32:00 rh Exp $

--- src/realpath.c.orig	Fri Feb 26 09:08:54 1999
+++ src/realpath.c	Sun Mar  7 15:53:38 1999
@@ -70,7 +70,8 @@
     if (result == NULL) /* result must not be null! */
       return(NULL);
 
-    if(pathname == NULL){ /* if pathname is null, there is nothing to do */
+    if(pathname == NULL || /* if pathname is null, there is nothing to do */
+       strlen (pathname) >= sizeof curpath) { /* pathname too long: bail out */
       *result = '\0'; 
       return(NULL);
     }
@@ -145,8 +146,15 @@
 
         for (last = namebuf; *last; last++)
             continue;
-        if ((last == namebuf) || (*--last != '/'))
+        if ((last == namebuf) || (*--last != '/')) {
+            if (strlen (namebuf) + 1 < sizeof (namebuf)) {
             strcat(namebuf, "/");
+            } else {
+                /* path too long: bail out */
+                *result = '\0';
+                return (NULL);
+            }
+        }
 
         if (strlen(namebuf) + strlen(where) + 1 < MAXPATHLEN)
 	  strcat(namebuf, where);
