$OpenBSD: patch-icb_serverlist_c,v 1.1 2001/05/14 16:42:54 millert Exp $
--- icb/serverlist.c.orig	Fri Feb 24 14:20:29 1995
+++ icb/serverlist.c	Mon May 14 10:33:04 2001
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include "icb.h"
@@ -16,7 +17,8 @@ FILE *openserverfile()
 	struct stat statbuf;
 	char *personalsl;
 	char command[256];
-	char pwd[256];
+	char pwd[MAXPATHLEN];
+	char *home;
 	FILE *ret;
 
 #ifdef sgi
@@ -25,15 +27,19 @@ FILE *openserverfile()
 #ifndef SYSV
 	getwd(pwd);
 #else /* SYSV */
-	getcwd(pwd, MAXPATHLEN+1);
+	getcwd(pwd, MAXPATHLEN);
 #endif /* SYSV */
 #ifdef sgi
 #define SYSV
 #endif
-	chdir(getenv("HOME"));
+	home = getenv("HOME");
+	if (!home)
+		errx(1, "can't get home directory from env");
+	chdir(home);
 	if (!stat(PERSONALSL,&statbuf))
 	{
-		sprintf(command,"/bin/cat %s %s\n", PERSONALSL, SERVERLIST);
+		snprintf(command, sizeof command, "/bin/cat %s %s\n",
+			 PERSONALSL, SERVERLIST);
 		ret= popen(command,"r");
 	}
 	else
