ash: exec: Stricter pathopt parsing
[oweals/busybox.git] / libbb / safe_gethostname.c
index 1290f4ca719fc7016f433705e0ad880de8f15739..b22e30ea355c43047fade0ce08510ac92fb94f8c 100644 (file)
@@ -4,9 +4,8 @@
  *
  * Copyright (C) 2008 Tito Ragusa <farmatito@tiscali.it>
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
-
 /*
  * SUSv2 guarantees that "Host names are limited to 255 bytes"
  * POSIX.1-2001 guarantees that "Host names (not including the terminating
@@ -23,7 +22,6 @@
  * Host software MUST handle host names of up to 63 characters and
  * SHOULD handle host names of up to 255 characters.
  */
-
 #include "libbb.h"
 #include <sys/utsname.h>
 
@@ -33,7 +31,7 @@
  * This is an illegal first character for a hostname.
  * The returned malloced string must be freed by the caller.
  */
-char *safe_gethostname(void)
+char* FAST_FUNC safe_gethostname(void)
 {
        struct utsname uts;
 
@@ -45,9 +43,8 @@ char *safe_gethostname(void)
         * name and an 8-byte nodename), but this is true on Linux. The same holds
         * for setdomainname(2) and the domainname field.
         */
-       
+
        /* Uname can fail only if you pass a bad pointer to it. */
        uname(&uts);
-
-       return xstrndup(!*(uts.nodename) ? "?" : uts.nodename, sizeof(uts.nodename));
+       return xstrndup(!uts.nodename[0] ? "?" : uts.nodename, sizeof(uts.nodename));
 }