diff -Naur util-linux-2.12q.orig/misc-utils/write.c util-linux-2.12q/misc-utils/write.c
--- util-linux-2.12q.orig/misc-utils/write.c	2001-03-15 12:09:58.000000000 +0200
+++ util-linux-2.12q/misc-utils/write.c	2005-06-11 16:00:56.000000000 +0300
@@ -64,9 +64,10 @@
 #include <paths.h>
 #include "pathnames.h"
 #include "carefulputc.h"
+#include "xgethostname.h"
 #include "nls.h"
  
-void search_utmp(char *, char *, char *, uid_t);
+void search_utmp(char *, char **, char *, uid_t);
 void do_write(char *, char *, uid_t);
 void wr_fputs(char *);
 static void done(int);
@@ -78,7 +79,7 @@
 	time_t atime;
 	uid_t myuid;
 	int msgsok, myttyfd;
-	char tty[MAXPATHLEN], *mytty;
+	char *tty, *mytty;
 
 	setlocale(LC_ALL, "");
 	bindtextdomain(PACKAGE, LOCALEDIR);
@@ -120,7 +121,7 @@
 	/* check args */
 	switch (argc) {
 	case 2:
-		search_utmp(argv[1], tty, mytty, myuid);
+		search_utmp(argv[1], &tty, mytty, myuid);
 		do_write(tty, mytty, myuid);
 		break;
 	case 3:
@@ -189,8 +190,10 @@
  *
  * Special case for writing to yourself - ignore the terminal you're
  * writing from, unless that's the only terminal with messages enabled.
+ *
+ * Returns tty as an allocated string.
  */
-void search_utmp(char *user, char *tty, char *mytty, uid_t myuid)
+void search_utmp(char *user, char **tty, char *mytty, uid_t myuid)
 
 {
 	struct utmp u;
@@ -224,7 +227,11 @@
 			++nttys;
 			if (atime > bestatime) {
 				bestatime = atime;
-				(void)strcpy(tty, atty);
+				if ((*tty = strdup(atty)) == NULL) {
+					(void)fprintf(stderr,
+						_("write: out of memory\n"));
+					exit(1);
+				}
 			}
 		}
 	}
@@ -236,7 +243,12 @@
 	}
 	if (nttys == 0) {
 		if (user_is_me) {		/* ok, so write to yourself! */
-			(void)strcpy(tty, mytty);
+			if ((*tty = strdup(mytty)) == NULL) {
+				(void)fprintf(stderr,
+					_("write: out of memory\n"));
+				exit(1);
+			}
+
 			return;
 		}
 		(void)fprintf(stderr,
@@ -245,7 +257,7 @@
 	} else if (nttys > 1) {
 		(void)fprintf(stderr,
 		    _("write: %s is logged in more than once; writing to %s\n"),
-		    user, tty);
+		    user, *tty);
 	}
 }
 
@@ -257,19 +269,23 @@
 
 {
 	struct stat s;
-	char path[MAXPATHLEN];
+	char *path;
 
-	if (strlen(tty) + 6 > sizeof(path))
-		return(1);
+	if ((path = malloc(strlen(tty) + sizeof("/dev/") + 1)) == NULL){
+		(void)fprintf(stderr,_("write: out of memory\n"));
+		exit(1);
+	}
 	(void)sprintf(path, "/dev/%s", tty);
 	if (stat(path, &s) < 0) {
 		if (showerror)
 			(void)fprintf(stderr,
 			    "write: %s: %s\n", path, strerror(errno));
+		free(path);
 		return(1);
 	}
 	*msgsokP = (s.st_mode & (S_IWRITE >> 3)) != 0;	/* group write bit */
 	*atimeP = s.st_atime;
+	free(path);
 	return(0);
 }
 
@@ -280,7 +296,7 @@
 	char *login, *pwuid, *nows;
 	struct passwd *pwd;
 	time_t now;
-	char path[MAXPATHLEN], host[MAXHOSTNAMELEN], line[512];
+	char *path, *host, *host_tmp, line[512];
 
 	/* Determine our login name(s) before the we reopen() stdout */
 	if ((pwd = getpwuid(myuid)) != NULL)
@@ -290,8 +306,10 @@
 	if ((login = getlogin()) == NULL)
 		login = pwuid;
 
-	if (strlen(tty) + 6 > sizeof(path))
+	if ((path = malloc(strlen(tty) + sizeof("/dev/") + 1)) == NULL) {
+		(void)fprintf(stderr, _("write: out of memory\n"));
 		exit(1);
+	}
 	(void)sprintf(path, "/dev/%s", tty);
 	if ((freopen(path, "w", stdout)) == NULL) {
 		(void)fprintf(stderr, "write: %s: %s\n",
@@ -299,12 +317,16 @@
 		exit(1);
 	}
 
+	free(path);
+
 	(void)signal(SIGINT, done);
 	(void)signal(SIGHUP, done);
 
 	/* print greeting */
-	if (gethostname(host, sizeof(host)) < 0)
-		(void)strcpy(host, "???");
+	if ((host_tmp = xgethostname()) != NULL)
+		host = host_tmp;
+	else
+		host = "???";
 	now = time((time_t *)NULL);
 	nows = ctime(&now);
 	nows[16] = '\0';
@@ -317,6 +339,8 @@
 			     login, host, mytty, nows + 11);
 	printf("\r\n");
 
+	free(host_tmp);
+
 	while (fgets(line, sizeof(line), stdin) != NULL)
 		wr_fputs(line);
 }
diff -Naur util-linux-2.12q.orig/misc-utils/namei.c util-linux-2.12q/misc-utils/namei.c
--- util-linux-2.12q.orig/misc-utils/namei.c	2004-12-23 01:03:39.000000000 +0200
+++ util-linux-2.12q/misc-utils/namei.c	2005-06-11 16:00:56.000000000 +0300
@@ -73,7 +73,8 @@
 main(int argc, char **argv) {
     extern int optind;
     int c;
-    char curdir[MAXPATHLEN];
+    int curdir_size;
+    char *curdir;
 
     setlocale(LC_ALL, "");
     bindtextdomain(PACKAGE, LOCALEDIR);
@@ -98,13 +99,28 @@
 	}
     }
 
-    if(getcwd(curdir, sizeof(curdir)) == NULL){
-	(void)fprintf(stderr,
-		      _("namei: unable to get current directory - %s\n"),
-		      curdir);
+    curdir_size = 1024;
+    curdir = malloc(curdir_size);
+    if (curdir==NULL){
+	(void)fprintf(stderr, _("namei: out of memory\n"));
 	exit(1);
     }
 
+    while (getcwd(curdir, curdir_size) == NULL){
+	if (errno!=ERANGE){
+	    (void)fprintf(stderr,
+			  _("namei: unable to get current directory - %s\n"),
+			  curdir);
+	    exit(1);
+	}
+	curdir_size *= 2;
+	realloc(curdir, curdir_size);
+	if (curdir==NULL){
+	    (void)fprintf(stderr, _("namei: out of memory\n"));
+	    exit(1);
+	}
+    }
+
 
     for(; optind < argc; optind++){
 	(void)printf("f: %s\n", argv[optind]);
diff -Naur util-linux-2.12q.orig/login-utils/wall.c util-linux-2.12q/login-utils/wall.c
--- util-linux-2.12q.orig/login-utils/wall.c	2002-03-09 01:00:19.000000000 +0200
+++ util-linux-2.12q/login-utils/wall.c	2005-06-11 16:00:56.000000000 +0300
@@ -58,6 +58,7 @@
 #include <utmp.h>
 
 #include "nls.h"
+#include "xgethostname.h"
 #include "xstrncpy.h"
 #include "ttymsg.h"
 #include "pathnames.h"
@@ -150,8 +151,7 @@
 	time_t now;
 	FILE *fp;
 	int fd;
-	char *p, *whom, *where, hostname[MAXHOSTNAMELEN],
-		lbuf[MAXHOSTNAMELEN + 320],
+	char *p, *whom, *where, *hostname, lbuf[1024],
 		tmpname[sizeof(_PATH_TMP) + 20];
 
 	(void)sprintf(tmpname, "%s/wall.XXXXXX", _PATH_TMP);
@@ -162,6 +162,9 @@
 	(void)unlink(tmpname);
 
 	if (!nobanner) {
+		char *mesg, *mesg_notice;
+		int mesg_size, size;
+
 		if (!(whom = getlogin()) || !*whom)
 			whom = (pw = getpwuid(getuid())) ? pw->pw_name : "???";
 		if (!whom || strlen(whom) > 100)
@@ -169,7 +172,11 @@
 		where = ttyname(2);
 		if (!where || strlen(where) > 100)
 			where = "somewhere";
-		(void)gethostname(hostname, sizeof(hostname));
+		if (!(hostname = xgethostname())) {
+			(void)fprintf(stderr, _("%s: can't get hostname.\n"),
+				progname);
+			exit(1);
+		}
 		(void)time(&now);
 		lt = localtime(&now);
 
@@ -182,13 +189,35 @@
 		 */
 		/* snprintf is not always available, but the sprintf's here
 		   will not overflow as long as %d takes at most 100 chars */
+
+		mesg_notice = _("Broadcast Message from %s@%s");
+		mesg_size = strlen(whom) + strlen(hostname) +
+			strlen(mesg_notice);
+		if (!(mesg = malloc(mesg_size))) {
+			(void)fprintf(stderr, _("%s: Out of memory!\n"),
+				progname);
+			exit(1);
+		}
+
 		(void)fprintf(fp, "\r%79s\r\n", " ");
-		(void)sprintf(lbuf, _("Broadcast Message from %s@%s"),
-			      whom, hostname);
-		(void)fprintf(fp, "%-79.79s\007\007\r\n", lbuf);
-		(void)sprintf(lbuf, "        (%s) at %d:%02d ...",
-			      where, lt->tm_hour, lt->tm_min);
-		(void)fprintf(fp, "%-79.79s\r\n", lbuf);
+		(void)sprintf(mesg, mesg_notice, whom, hostname);
+		(void)fprintf(fp, "%-79.79s\007\007\r\n", mesg);
+
+		mesg_notice = "        (%s) at %d:%02d ...";
+		size = strlen(mesg_notice) + strlen(where);
+		if (mesg_size < size) {
+			if (!realloc(mesg, size)) {
+				(void)fprintf(stderr, _("%s: Out of memory!\n"),
+					progname);
+				exit(1);
+			}
+		}
+
+		(void)sprintf(mesg, mesg_notice, where,
+			lt->tm_hour, lt->tm_min);
+		(void)fprintf(fp, "%-79.79s\r\n", mesg);
+
+		free(mesg);
 	}
 	(void)fprintf(fp, "%79s\r\n", " ");
 
diff -Naur util-linux-2.12q.orig/login-utils/last.c util-linux-2.12q/login-utils/last.c
--- util-linux-2.12q.orig/login-utils/last.c	2002-03-09 00:59:41.000000000 +0200
+++ util-linux-2.12q/login-utils/last.c	2005-06-11 16:00:56.000000000 +0300
@@ -49,6 +49,7 @@
 
 #include "pathnames.h"
 #include "nls.h"
+#include "xgethostname.h"
 
 #define	SECDAY	(24*60*60)			/* seconds in a day */
 #define	NO	0				/* false/no */
@@ -430,15 +431,15 @@
 hostconv(char *arg) {
 	static int	first = 1;
 	static char	*hostdot,
-			name[MAXHOSTNAMELEN];
+			*name;
 	char	*argdot;
 
 	if (!(argdot = strchr(arg, '.')))
 		return;
 	if (first) {
 		first = 0;
-		if (gethostname(name, sizeof(name))) {
-			perror(_("last: gethostname"));
+		if (!(name = xgethostname())) {
+			perror(_("last: can't get hostname"));
 			exit(1);
 		}
 		hostdot = strchr(name, '.');
diff -Naur util-linux-2.12q.orig/login-utils/agetty.c util-linux-2.12q/login-utils/agetty.c
--- util-linux-2.12q.orig/login-utils/agetty.c	2002-07-29 10:36:42.000000000 +0300
+++ util-linux-2.12q/login-utils/agetty.c	2005-06-11 16:00:56.000000000 +0300
@@ -30,7 +29,7 @@
 #include <getopt.h>
 #include <time.h>
 #include <sys/file.h>
+#include "xgethostname.h"
 #include "xstrncpy.h"
 #include "nls.h"
 
@@ -947,12 +928,14 @@
 	(void) fclose(fd);
     }
 #endif
-#ifdef __linux__
+#if defined(unix)
 	{
-		char hn[MAXHOSTNAMELEN+1];
+		char *hn;
 
-		(void) gethostname(hn, MAXHOSTNAMELEN);
+		if (!(hn = xgethostname()))
+			error(_("can't get hostname"));
 		write(1, hn, strlen(hn));
+		free(hn);
 	}
 #endif		
     (void) write(1, LOGIN, sizeof(LOGIN) - 1);	/* always show login prompt */
diff -Naur util-linux-2.12q.orig/lib/README.xgethostname util-linux-2.12q/lib/README.xgethostname
--- util-linux-2.12q.orig/lib/README.xgethostname	1970-01-01 02:00:00.000000000 +0200
+++ util-linux-2.12q/lib/README.xgethostname	2005-06-11 16:00:56.000000000 +0300
@@ -0,0 +1,76 @@
+A wrapper for gethostname that automatically checks system limitations.
+
+Latest version can always be found at:
+ftp://walfield.org/pub/people/neal/xgethostname/xgethostname-latest.tar.gz
+
+Author:
+Neal H Walfield <neal@cs.uml.edu>
+
+Version:
+April 13, 2002
+
+ChangeLog:
+2002-04-13  Neal H Walfield  <neal@walfield.org>
+
+	* VERSION: Update to 20010413.
+	* Release version 20010413.
+	
+2002-04-13  Neal H Walfield  <neal@walfield.org>
+
+	* xgethostname.c (xgethostname): gethostname returns -1 on error,
+	not the error code.  There is no need to use realloc as it copies
+	the unused buffer.
+
+2001-08-03  Neal H Walfield  <neal@cs.uml.edu>
+
+	* VERSION: Update to 20010803.
+	* Release version 20010803.
+
+2001-08-03  Neal H Walfield  <neal@cs.uml.edu>
+
+	* Makefile: Make no assumptions about the make that the user
+	will be using.
+	* xgethostname.c (xgethostname): Be explicitly sure that the
+	returned buffer is NULL terminated.
+	Always compile in the while (err = ENAMETOOLONG) loop; this
+	may help to catch a very exotic implementation and does not
+	hurt anyone.
+
+2001-08-02  Neal H Walfield  <neal@cs.uml.edu>
+
+	* Release version 20010802.
+
+2001-08-01  Neal H Walfield  <neal@cs.uml.edu>
+
+	* Makefile: New file.
+	* README: New file.
+	* xgethostname.c (xgethostname) [!_SC_HOST_NAME_MAX]: Should
+	not be subject to this condition.
+	(xgethostname): If the system defines a limit < 256 and > 0,
+	do not artificially inflate it, rather, respect it.
+
+2001-07-30  Neal H Walfield  <neal@cs.uml.edu>
+
+	* REAMME: Move from here . . .
+	* xgethostname.2: to here.
+	Format it for man.
+
+2001-07-30  Neal H Walfield  <neal@cs.uml.edu>
+
+	* README: Fix grammer error.
+	* xgethostname.c: Likewise.
+	* xgethostname.h: Likewise.
+
+	* Makefile: New file.
+
+2001-07-29  Neal H Walfield  <neal@cs.uml.edu>
+
+	* Release version 20010729.
+
+	* AUTHOR: New file.
+	* ChangeLog: New file.
+	* COPYING: New file.
+	* README: New file.
+	* VERSION: New file.
+	* xgethostname.c: New file.
+	* xgethostname.h: New file.
diff -Naur util-linux-2.12q.orig/lib/xgethostname.2 util-linux-2.12q/lib/xgethostname.2
--- util-linux-2.12q.orig/lib/xgethostname.2	1970-01-01 02:00:00.000000000 +0200
+++ util-linux-2.12q/lib/xgethostname.2	2005-06-11 16:00:56.000000000 +0300
@@ -0,0 +1,37 @@
+.TH XGETHOSTNAME 2 "30 July 2001" "xgethostname"
+.SH NAME
+xgethostname \- get the host name.
+.SH
+SYNOPSIS
+.BI "char *xgethostname (void);"
+.SH DESCRIPTION
+The xhostname function is intended to replace
+.BR gethostname(2),
+a function used to access the host name.  The old interface is
+inflexable given that it assumes the existance of the
+.BR MAXHOSTNAMELEN
+macro, which neither
+.BR POSIX
+nor the proposed
+.BR "Single Unix Specification version 3"
+guarantee to be defined.
+.SH RETURN VALUE
+On success, a malloced, null terminated (possibly truncated)
+string containing the host name is returned.  On failure,
+.I NULL
+is returned and errno is set.
+.SH ERRORS
+.TP
+.BR ENOMEM
+Failed to allocate memory.
+.LP
+As 
+.BR xgethostname
+is really just a wrapper around your systems
+.BR gethostname (2),
+see that man page for additional details.
+.SH "SEE ALSO"
+.BR gethostname (2)
+.SH AUTHOR
+.BR xgethostname
+was written by Neal H Walfield  <neal@cs.uml.edu>.
diff -Naur util-linux-2.12q.orig/lib/xgethostname.c util-linux-2.12q/lib/xgethostname.c
--- util-linux-2.12q.orig/lib/xgethostname.c	1970-01-01 02:00:00.000000000 +0200
+++ util-linux-2.12q/lib/xgethostname.c	2005-06-11 16:00:56.000000000 +0300
@@ -0,0 +1,126 @@
+/* Copyright (c) 2001 Neal H Walfield <neal@cs.uml.edu>.
+   
+   This file is placed into the public domain.  Its distribution
+   is unlimited.
+
+   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+   IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
+   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+   IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+   IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* NAME
+
+	xgethostname - get the host name.
+
+   SYNOPSIS
+
+   	char *xgethostname (void);
+
+   DESCRIPTION
+
+	The xhostname function is intended to replace gethostname(2), a
+	function used to access the host name.  The old interface is
+	inflexable given that it assumes the existance of the
+	MAXHOSTNAMELEN macro, which neither POSIX nor the proposed
+	Single Unix Specification version 3 guarantee to be defined.
+
+   RETURN VALUE
+
+	On success, a malloced, null terminated (possibly truncated)
+	string containing the host name is returned.  On failure,
+	NULL is returned and errno is set.
+ */
+
+#include <sys/param.h>	/* For MAXHOSTNAMELEN */
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include "xgethostname.h"
+
+char *
+xgethostname (void)
+{
+  int size = 0;
+  int addnull = 0;
+  char *buf;
+  int err;
+
+#ifdef MAXHOSTNAMELEN
+  size = MAXHOSTNAMELEN;
+  addnull = 1;
+#else /* MAXHOSTNAMELEN */
+#ifdef _SC_HOST_NAME_MAX
+  size = sysconf (_SC_HOST_NAME_MAX);
+  addnull = 1;
+#endif /* _SC_HOST_NAME_MAX */
+  if (size <= 0)
+    size = 256;
+#endif /* MAXHOSTNAMELEN */
+
+  buf = malloc (size + addnull);
+  if (! buf)
+    {
+      errno = ENOMEM;
+      return NULL;
+    }
+
+  err = gethostname (buf, size);
+  while (err == -1 && errno == ENAMETOOLONG)
+    {
+      free (buf);
+
+      size *= 2;
+      buf = malloc (size + addnull);
+      if (! buf)
+	{
+	  errno = ENOMEM;
+	  return NULL;
+	}
+      
+      err = gethostname (buf, size);
+    }
+
+  if (err)
+    {
+      if (buf)
+        free (buf);
+      errno = err;
+      return NULL;
+    }
+
+  if (addnull)
+    buf[size] = '\0';
+
+  return buf;
+}
+
+#ifdef WANT_TO_TEST_XGETHOSTNAME
+#include <stdio.h>
+#include <string.h>
+
+int
+main (int argc, char *argv[])
+{
+  char *hostname;
+
+  hostname = xgethostname ();
+  if (! hostname)
+    {
+      perror ("xgethostname");
+      return 1;
+    }
+
+  printf ("%s\n", hostname);
+  free (hostname);
+
+  return 0;
+}
+#endif /* WANT_TO_TEST_XGETHOSTNAME */
diff -Naur util-linux-2.12q.orig/lib/xgethostname.h util-linux-2.12q/lib/xgethostname.h
--- util-linux-2.12q.orig/lib/xgethostname.h	1970-01-01 02:00:00.000000000 +0200
+++ util-linux-2.12q/lib/xgethostname.h	2005-06-11 16:00:56.000000000 +0300
@@ -0,0 +1,48 @@
+/* Copyright (c) 2001 Neal H Walfield <neal@cs.uml.edu>.
+   
+   This file is placed into the public domain.  Its distribution
+   is unlimited.
+
+   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+   IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
+   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+   IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+   IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* NAME
+
+	xgethostname - get the host name.
+
+   SYNOPSIS
+
+   	char *xgethostname (void);
+
+   DESCRIPTION
+
+	The xhostname function is intended to replace gethostname(2), a
+	function used to access the host name.  The old interface is
+	inflexable given that it assumes the existance of the
+	MAXHOSTNAMELEN macro, which neither POSIX nor the proposed
+	Single Unix Specification version 3 guarantee to be defined.
+
+   RETURN VALUE
+
+	On success, a malloced, null terminated (possibly truncated)
+	string containing the host name is returned.  On failure,
+	NULL is returned and errno is set.
+ */
+
+#ifndef XGETHOSTNAME
+#define XGETHOSTNAME
+
+char * xgethostname (void);
+
+#endif /* XGETHOSTNAME */
+
diff -Naur util-linux-2.12q.orig/fdisk/fdiskbsdlabel.c util-linux-2.12q/fdisk/fdiskbsdlabel.c
--- util-linux-2.12q.orig/fdisk/fdiskbsdlabel.c	2003-07-14 00:12:47.000000000 +0300
+++ util-linux-2.12q/fdisk/fdiskbsdlabel.c	2005-06-11 16:00:56.000000000 +0300
@@ -52,7 +52,6 @@
 #include <errno.h>
 #include "nls.h"
 
 #include <sys/ioctl.h>
-#include <sys/param.h>
 
 #include "common.h"
@@ -515,7 +514,7 @@
 xbsd_write_bootstrap (void)
 {
   char *bootdir = BSD_LINUX_BOOTDIR;
-  char path[MAXPATHLEN];
+  char *path;
   char *dkbasename;
   struct xbsd_disklabel dl;
   char *d, *p, *e;
@@ -532,9 +531,15 @@
     line_ptr[strlen (line_ptr)-1] = '\0';
     dkbasename = line_ptr;
   }
-  snprintf (path, sizeof(path), "%s/%sboot", bootdir, dkbasename);
-  if (!xbsd_get_bootstrap (path, disklabelbuffer, (int) xbsd_dlabel.d_secsize))
+  path = (char *) malloc (sizeof("/boot") + 1 + strlen (bootdir) +
+			  strlen (dkbasename));
+  if (!path)
+    fatal (out_of_memory);
+  sprintf (path, "%s/%sboot", bootdir, dkbasename);
+  if (!xbsd_get_bootstrap (path, disklabelbuffer, (int) xbsd_dlabel.d_secsize)) {
+    free (path);
     return;
+  }
 
   /* We need a backup of the disklabel (xbsd_dlabel might have changed). */
   d = &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE];
@@ -543,10 +548,13 @@
   /* The disklabel will be overwritten by 0's from bootxx anyway */
   bzero (d, sizeof (struct xbsd_disklabel));
 
+  sprintf (path, "%s/boot%s", bootdir, dkbasename);
   snprintf (path, sizeof(path), "%s/boot%s", bootdir, dkbasename);
   if (!xbsd_get_bootstrap (path, &disklabelbuffer[xbsd_dlabel.d_secsize],
-			  (int) xbsd_dlabel.d_bbsize - xbsd_dlabel.d_secsize))
+			  (int) xbsd_dlabel.d_bbsize - xbsd_dlabel.d_secsize)) {
+    free(path);
     return;
+  }
 
   e = d + sizeof (struct xbsd_disklabel);
   for (p=d; p < e; p++)
@@ -579,6 +587,8 @@
 #endif
 
   sync_disks ();
+
+  free(path);
 }
 
 static void
diff -Naur util-linux-2.12q.orig/misc-utils/Makefile util-linux-2.12q/misc-utils/Makefile
--- util-linux-2.12q.orig/misc-utils/Makefile	2004-12-05 21:09:12.000000000 +0200
+++ util-linux-2.12q/misc-utils/Makefile	2005-06-11 16:00:56.000000000 +0300
@@ -96,8 +96,8 @@
 mcookie.o: mcookie.c $(LIB)/md5.h
 reset: reset.sh
 script: script.o
-write.o: $(LIB)/carefulputc.h
-write: write.o $(LIB)/carefulputc.o
+write.o: $(LIB)/carefulputc.h $(LIB)/xgethostname.h
+write: write.o $(LIB)/carefulputc.o $(LIB)/xgethostname.o
 
 ifeq "$(HAVE_NCURSES)" "yes"
 setterm: setterm.o
diff -Naur util-linux-2.12q.orig/lib/Makefile util-linux-2.12q/lib/Makefile
--- util-linux-2.12q.orig/lib/Makefile	2002-11-02 15:51:26.000000000 +0200
+++ util-linux-2.12q/lib/Makefile	2005-06-11 16:00:56.000000000 +0300
@@ -1,11 +1,12 @@
 include ../make_include
 include ../MCONFIG
 
-all: err.o my_reboot.o setproctitle.o env.o carefulputc.o xstrncpy.o md5.o
+all: err.o my_reboot.o setproctitle.o env.o carefulputc.o md5.o \
+	xgethostname.o xstrncpy.o
 
 err.o: err.c
 
 my_reboot.o: my_reboot.c linux_reboot.h
 
 env.o: env.h
 
@@ -15,6 +16,8 @@
 
 xstrncpy.o: xstrncpy.h
 
+xgethostname.o: xgethostname.h
+
 md5.o: md5.c md5.h
 
 .PHONY: clean
diff -Naur util-linux-2.12q.orig/login-utils/login.c util-linux-2.12q/login-utils/login.c
--- util-linux-2.12q.orig/login-utils/login.c	2004-12-05 04:37:12.000000000 +0200
+++ util-linux-2.12q/login-utils/login.c	2005-06-11 16:00:56.000000000 +0300
@@ -116,6 +116,7 @@
 #include "my_crypt.h"
 #include "login.h"
 #include "xstrncpy.h"
+#include "xgethostname.h"
 #include "nls.h"
 
 #ifdef __linux__
@@ -202,10 +203,6 @@
 
 #define	TTYGRPNAME	"tty"		/* name of group to own ttys */
 
-#ifndef MAXPATHLEN
-#  define MAXPATHLEN 1024
-#endif
-
 /*
  * This bounds the time given to login.  Not a define so it can
  * be patched on machines where it's too small.
@@ -223,7 +220,7 @@
 char    hostaddress[4];		/* used in checktty.c */
 char	*hostname;		/* idem */
 static char	*username, *tty_name, *tty_number;
-static char	thishost[100];
+static char	*thishost;
 static int	failures = 1;
 static pid_t	pid;
 
@@ -356,7 +355,7 @@
     int ask, fflag, hflag, pflag, cnt, errsv;
     int quietlog, passwd_req;
     char *domain, *ttyn;
-    char tbuf[MAXPATHLEN + 2], tname[sizeof(_PATH_TTY) + 10];
+    char tname[sizeof(_PATH_TTY) + 10];
     char *termenv;
     char *childArgv[10];
     char *buff;
@@ -398,9 +397,11 @@
      * -h is used by other servers to pass the name of the remote
      *    host to login so that it may be placed in utmp and wtmp
      */
-    gethostname(tbuf, sizeof(tbuf));
-    xstrncpy(thishost, tbuf, sizeof(thishost));
-    domain = index(tbuf, '.');
+    if (!(thishost = xgethostname())) {
+	    fprintf(stderr, _("login: can't get hostname\n"));
+	    exit(1);
+    }
+    domain = index(thishost, '.');
     
     username = tty_name = hostname = NULL;
     fflag = hflag = pflag = 0;
@@ -861,23 +862,21 @@
        having the BSD setreuid() */
     
     {
-	char tmpstr[MAXPATHLEN];
+	char *tmpstr;
 	uid_t ruid = getuid();
 	gid_t egid = getegid();
 
 	/* avoid snprintf - old systems do not have it, or worse,
 	   have a libc in which snprintf is the same as sprintf */
-	if (strlen(pwd->pw_dir) + sizeof(_PATH_HUSHLOGIN) + 2 > MAXPATHLEN)
-		quietlog = 0;
-	else {
-		sprintf(tmpstr, "%s/%s", pwd->pw_dir, _PATH_HUSHLOGIN);
-		setregid(-1, pwd->pw_gid);
-		setreuid(0, pwd->pw_uid);
-		quietlog = (access(tmpstr, R_OK) == 0);
-		setuid(0); /* setreuid doesn't do it alone! */
-		setreuid(ruid, 0);
-		setregid(-1, egid);
-	}
+	tmpstr = malloc(strlen(pwd->pw_dir) + sizeof(_PATH_HUSHLOGIN) + 2);
+	sprintf(tmpstr, "%s/%s", pwd->pw_dir, _PATH_HUSHLOGIN);
+	setregid(-1, pwd->pw_gid);
+	setreuid(0, pwd->pw_uid);
+	quietlog = (access(tmpstr, R_OK) == 0);
+	setuid(0); /* setreuid doesn't do it alone! */
+	setreuid(ruid, 0);
+	setregid(-1, egid);
+	free(tmpstr);
     }
     
     /* for linux, write entries in utmp and wtmp */
@@ -1028,12 +1027,13 @@
     
     /* mailx will give a funny error msg if you forget this one */
     {
-      char tmp[MAXPATHLEN];
+      char *tmp;
+
       /* avoid snprintf */
-      if (sizeof(_PATH_MAILDIR) + strlen(pwd->pw_name) + 1 < MAXPATHLEN) {
-	      sprintf(tmp, "%s/%s", _PATH_MAILDIR, pwd->pw_name);
-	      setenv("MAIL",tmp,0);
-      }
+      tmp = malloc(sizeof(_PATH_MAILDIR) + strlen(pwd->pw_name) + 2);
+      sprintf(tmp, "%s/%s", _PATH_MAILDIR, pwd->pw_name);
+      setenv("MAIL", tmp, 0);
+      free(tmp);
     }
     
     /* LOGNAME is not documented in login(1) but
@@ -1191,13 +1191,15 @@
 	childArgv[childArgc++] = "-c";
 	childArgv[childArgc++] = buff;
     } else {
-	tbuf[0] = '-';
-	xstrncpy(tbuf + 1, ((p = rindex(pwd->pw_shell, '/')) ?
-			   p + 1 : pwd->pw_shell),
-		sizeof(tbuf)-1);
+	char *tbuf, *shell_cmd;
+
+	tbuf = ((p = rindex(pwd->pw_shell, '/')) ? p + 1 : pwd->pw_shell);
+	shell_cmd = malloc(strlen(tbuf));
+	shell_cmd[0] = '-';
+	xstrncpy(shell_cmd + 1, tbuf, strlen(tbuf)-1);
 	
 	childArgv[childArgc++] = pwd->pw_shell;
-	childArgv[childArgc++] = tbuf;
+	childArgv[childArgc++] = shell_cmd;
     }
 
     childArgv[childArgc++] = NULL;
diff -Naur util-linux-2.12q.orig/login-utils/Makefile util-linux-2.12q/login-utils/Makefile
--- util-linux-2.12q.orig/login-utils/Makefile	2004-11-23 18:06:57.000000000 +0200
+++ util-linux-2.12q/login-utils/Makefile	2005-06-11 16:00:56.000000000 +0300
@@ -97,17 +102,18 @@
 wall.o: ttymsg.h $(LIB)/carefulputc.h
 
-agetty: agetty.o $(LIB)/xstrncpy.o
+agetty: agetty.o $(LIB)/xstrncpy.o $(LIB)/xgethostname.o
 chfn: chfn.o islocal.o setpwnam.o $(SELINUXOBJS) $(LIB)/env.o $(LIB)/xstrncpy.o
 	$(CC) $(LDFLAGS) -o $@ $^ $(CRYPT) $(PAM) $(SELINUXLLIB)
 chsh: chsh.o islocal.o setpwnam.o $(SELINUXOBJS) $(LIB)/env.o
 	$(CC) $(LDFLAGS) -o $@ $^ $(CRYPT) $(PAM) $(SELINUXLLIB)
-last: last.o
+last: last.o $(LIB)/xgethostname.o
 
 ifeq "$(HAVE_PAM)" "yes"
-login: login.o $(LIB)/setproctitle.o $(LIB)/xstrncpy.o
+login: login.o $(LIB)/setproctitle.o $(LIB)/xstrncpy.o $(LIB)/xgethostname.o
 	$(CC) $(LDFLAGS) -o $@ $^ $(CRYPT) $(PAM) $(SELINUXLLIB)
 else
-login: login.o $(LIB)/xstrncpy.o $(LIB)/setproctitle.o checktty.o 
+login: login.o $(LIB)/xstrncpy.o $(LIB)/xgethostname.o $(LIB)/setproctitle.o \
+		checktty.o
 	$(CC) $(LDFLAGS) -o $@ $^ $(CRYPT) $(SELINUXLLIB)
 endif
 
@@ -134,7 +140,8 @@
 newgrp.o: $(LIB)/pathnames.h
 	$(CC) -c $(CFLAGS) $(PAMFL) newgrp.c 
 
-wall: wall.o ttymsg.o $(LIB)/carefulputc.o $(LIB)/xstrncpy.o
+wall: wall.o ttymsg.o $(LIB)/carefulputc.o $(LIB)/xstrncpy.o \
+		$(LIB)/xgethostname.o
 
 LOGINFLAGS=
 ifeq "$(USE_TTY_GROUP)" "yes"
@@ -147,7 +147,8 @@
 	LOGINFLAGS += -DDO_STAT_MAIL
 endif
 
-login.o: login.c $(LIB)/pathnames.h $(LIB)/setproctitle.c $(LIB)/setproctitle.h
+login.o: login.c $(LIB)/pathnames.h $(LIB)/setproctitle.c \
+		$(LIB)/setproctitle.h $(LIB)/xgethostname.h
 	$(CC) -c $(CFLAGS) $(PAMFL) $(LOGINFLAGS) login.c
 
 # LOGINFLAGS here only for -DUSE_TTY_GROUP
