rfelker writes in Bug 742: make sure string is null terminated after calling gethostname
authorMike Frysinger <vapier@gentoo.org>
Sun, 19 Feb 2006 23:03:31 +0000 (23:03 -0000)
committerMike Frysinger <vapier@gentoo.org>
Sun, 19 Feb 2006 23:03:31 +0000 (23:03 -0000)
libbb/login.c

index 3f67a819a947f82e67a97870c32876e12ff26522..2d6162564ec12b71849290d27b000ea3056d40d9 100644 (file)
@@ -96,6 +96,7 @@ void print_login_issue(const char *issue_file, const char *tty)
 
                                        case 'h':
                                                gethostname(buf, sizeof(buf) - 1);
+                                               buf[sizeof(buf) - 1] = '\0';
                                                break;
 
                                        case 'l':
@@ -105,7 +106,7 @@ void print_login_issue(const char *issue_file, const char *tty)
                                        default:
                                                buf[0] = c;
                                }
-               }
+                       }
                        fputs(outbuf, stdout);
                }