diff --git a/hostname.c b/hostname.c index 4a377d9..5a8b2eb 100644 --- a/hostname.c +++ b/hostname.c @@ -1,8 +1,9 @@ /* See LICENSE file for copyright and license details. */ -#include +#include #include #include #include +#include #include "util.h" static void @@ -14,7 +15,7 @@ usage(void) int main(int argc, char *argv[]) { - char buf[BUFSIZ]; + char host[HOST_NAME_MAX + 1]; ARGBEGIN { default: @@ -22,9 +23,9 @@ main(int argc, char *argv[]) } ARGEND; if (argc < 1) { - if (gethostname(buf, sizeof(buf)) < 0) + if (gethostname(host, sizeof(host)) < 0) eprintf("gethostname:"); - puts(buf); + puts(host); } else { if (sethostname(argv[0], strlen(argv[0])) < 0) eprintf("sethostname:");