[Hostname-devel] [SCM] Git repository for hostname branch, master, updated. debian/2.96-49-gce2a4a2

Michael Meskes meskes at debian.org
Thu Dec 22 15:45:20 UTC 2011


The following commit has been merged in the master branch:
commit 0c8a8226368f878a28a325b99ef716349244068e
Author: Michael Meskes <meskes at debian.org>
Date:   Thu Dec 22 16:29:39 2011 +0100

    Strip leading and trailing whitespaces from hostname.
    
    Closes: #650822

diff --git a/debian/changelog b/debian/changelog
index 303bc76..bca277f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+hostname (3.07) unstable; urgency=low
+
+  * Strip leading and trailing whitespaces from hostname. (Closes: #650822)
+
+ -- Michael Meskes <meskes at debian.org>  Thu, 22 Dec 2011 16:31:05 +0100
+
 hostname (3.06) unstable; urgency=low
 
   * Relax version comparison to make binnmus possible. (Closes: #616683)
diff --git a/hostname.c b/hostname.c
index f687067..360fc19 100644
--- a/hostname.c
+++ b/hostname.c
@@ -45,7 +45,7 @@
 #include <err.h>
 #include <rpcsvc/ypclnt.h>
 
-#define VERSION "3.06"
+#define VERSION "3.07"
 
 enum type_t { DEFAULT, DNS, FQDN, SHORT, ALIAS, IP, NIS, NIS_DEF, ALL_FQDNS, ALL_IPS };
 
@@ -210,8 +210,17 @@ check_name(char *name)
 void
 set_name(enum type_t type, char *name)
 {
+	int i;
+
 	switch (type) {
 	case DEFAULT:
+		/* Whitespaces are invalid characters in a hostname. */
+		/* Thus remove trailing and leading whitespaces. */
+		while (isspace(*name)) { name++; }
+		for (i = strlen(name) - 1; isspace(name[i]); i--);       
+		name[i+1] = '\0';
+
+		/* Now check for a valid name. */
 		if (!check_name(name))
 			errx(1, "the specified hostname is invalid");
 

-- 
Git repository for hostname



More information about the Hostname-devel mailing list