[hackers] [sbase] Audit hostname(1) || FRIGN
commit dad8dec550b94b5db7dc97b77a34ca0a26ad44ca
Author: FRIGN <dev_AT_frign.de>
Date: Sat Feb 28 21:22:55 2015 +0100
Audit hostname(1)
1) Be strict about argc
2) Fix a small error in the manpage
diff --git a/README b/README
index 870b497..363536b 100644
--- a/README
+++ b/README
_AT_@ -35,7 +35,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support,
#* fold yes none
=* grep yes none
=* head yes none
-=* hostname non-posix none
+=*| hostname non-posix none
=* kill yes none
=*| link yes none
=* ln yes none
diff --git a/hostname.1 b/hostname.1
index 28dc4df..9be4b1d 100644
--- a/hostname.1
+++ b/hostname.1
_AT_@ -1,4 +1,4 @@
-.Dd January 30, 2015
+.Dd February 28, 2015
.Dt HOSTNAME 1
.Os sbase
.Sh NAME
_AT_@ -13,6 +13,6 @@ sets the current host name to
.Ar name .
If no
.Ar name
-is given, the current hostname is written to stdout.
+is given, the current host name is written to stdout.
.Sh SEE ALSO
.Xr hostname 7
diff --git a/hostname.c b/hostname.c
index 55ed0ca..2aad4ad 100644
--- a/hostname.c
+++ b/hostname.c
_AT_@ -21,13 +21,16 @@ main(int argc, char *argv[])
usage();
} ARGEND;
- if (argc < 1) {
+ if (!argc) {
if (gethostname(host, sizeof(host)) < 0)
eprintf("gethostname:");
puts(host);
- } else {
+ } else if (argc == 1) {
if (sethostname(argv[0], strlen(argv[0])) < 0)
eprintf("sethostname:");
+ } else {
+ usage();
}
+
return 0;
}
Received on Sat Feb 28 2015 - 22:12:23 CET
This archive was generated by hypermail 2.3.0
: Sat Feb 28 2015 - 22:24:12 CET