aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-02-20 16:31:44 +0000
committerlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-02-20 16:31:44 +0000
commiteac2c55c31316598850b79c020e779eff0e874b3 (patch)
tree5210a3650324d0093bca21b9755d58b04ba220ce
parente3599f6186b7bc00f91e1ef163d3e29e31d32e7a (diff)
downloadbusybox-w32-eac2c55c31316598850b79c020e779eff0e874b3.tar.gz
busybox-w32-eac2c55c31316598850b79c020e779eff0e874b3.tar.bz2
busybox-w32-eac2c55c31316598850b79c020e779eff0e874b3.zip
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. git-svn-id: svn://busybox.net/trunk/busybox@14147 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--libbb/login.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/libbb/login.c b/libbb/login.c
index 98799dc49..2d6162564 100644
--- a/libbb/login.c
+++ b/libbb/login.c
@@ -37,7 +37,7 @@ void print_login_issue(const char *issue_file, const char *tty)
37{ 37{
38 FILE *fd; 38 FILE *fd;
39 int c; 39 int c;
40 char buf[256+2]; 40 char buf[256];
41 const char *outbuf; 41 const char *outbuf;
42 time_t t; 42 time_t t;
43 struct utsname uts; 43 struct utsname uts;
@@ -82,8 +82,8 @@ void print_login_issue(const char *issue_file, const char *tty)
82 82
83 case 'D': 83 case 'D':
84 case 'o': 84 case 'o':
85 buf[0] = '\0'; 85 getdomainname(buf, sizeof(buf));
86 getdomainname(buf, sizeof(buf) - 1); 86 buf[sizeof(buf) - 1] = '\0';
87 break; 87 break;
88 88
89 case 'd': 89 case 'd':
@@ -95,8 +95,8 @@ void print_login_issue(const char *issue_file, const char *tty)
95 break; 95 break;
96 96
97 case 'h': 97 case 'h':
98 buf[0] = '\0';
99 gethostname(buf, sizeof(buf) - 1); 98 gethostname(buf, sizeof(buf) - 1);
99 buf[sizeof(buf) - 1] = '\0';
100 break; 100 break;
101 101
102 case 'l': 102 case 'l':
@@ -120,8 +120,8 @@ void print_login_prompt(void)
120{ 120{
121 char buf[MAXHOSTNAMELEN+1]; 121 char buf[MAXHOSTNAMELEN+1];
122 122
123 if(gethostname(buf, MAXHOSTNAMELEN) == 0) 123 gethostname(buf, MAXHOSTNAMELEN);
124 fputs(buf, stdout); 124 fputs(buf, stdout);
125 125
126 fputs(LOGIN, stdout); 126 fputs(LOGIN, stdout);
127 fflush(stdout); 127 fflush(stdout);