svn commit: trunk/busybox/libbb

landley at busybox.net landley at busybox.net
Mon Feb 20 16:31:46 UTC 2006


Author: landley
Date: 2006-02-20 08:31:44 -0800 (Mon, 20 Feb 2006)
New Revision: 14147

Log:
getdomainname() isn't guaranteed to null terminate the string if it was
truncated for length.  SVN 14135 made sure that the truncated version would
always be null terminated.  SVN 14144 broke this for no readily apparent
reason, and I have no idea what it was even trying to accomplish.  Reverted.


Modified:
   trunk/busybox/libbb/login.c


Changeset:
Modified: trunk/busybox/libbb/login.c
===================================================================
--- trunk/busybox/libbb/login.c	2006-02-20 14:39:55 UTC (rev 14146)
+++ trunk/busybox/libbb/login.c	2006-02-20 16:31:44 UTC (rev 14147)
@@ -37,7 +37,7 @@
 {
 	FILE *fd;
 	int c;
-	char buf[256+2];
+	char buf[256];
 	const char *outbuf;
 	time_t t;
 	struct utsname uts;
@@ -82,8 +82,8 @@
 
 					case 'D':
 					case 'o':
-						buf[0] = '\0';
-						getdomainname(buf, sizeof(buf) - 1);
+						getdomainname(buf, sizeof(buf));
+						buf[sizeof(buf) - 1] = '\0';
 						break;
 
 					case 'd':
@@ -95,8 +95,8 @@
 						break;
 
 					case 'h':
-						buf[0] = '\0';
 						gethostname(buf, sizeof(buf) - 1);
+						buf[sizeof(buf) - 1] = '\0';
 						break;
 
 					case 'l':
@@ -120,8 +120,8 @@
 {
 	char buf[MAXHOSTNAMELEN+1];
 
-	if(gethostname(buf, MAXHOSTNAMELEN) == 0)
-		fputs(buf, stdout);
+	gethostname(buf, MAXHOSTNAMELEN);
+	fputs(buf, stdout);
 
 	fputs(LOGIN, stdout);
 	fflush(stdout);




More information about the busybox-cvs mailing list