about summary refs log tree commit diff
path: root/inet/ether_line.c
diff options
context:
space:
mode:
Diffstat (limited to 'inet/ether_line.c')
-rw-r--r--inet/ether_line.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/inet/ether_line.c b/inet/ether_line.c
index 7e871a6bd7..13c5f394cf 100644
--- a/inet/ether_line.c
+++ b/inet/ether_line.c
@@ -61,19 +61,20 @@ ether_line (const char *line, struct ether_addr *addr, char *hostname)
 	++line;
     }
 
-  /* Remove trailing white space.  */
-  cp = __strchrnul (line, '#');
-  while (cp > line && isspace (cp[-1]))
-    --cp;
+  /* Skip initial whitespace.  */
+  while (isspace (*line))
+    ++line;
 
-  if (cp == line)
+  if (*line == '#' || *line == '\0')
     /* No hostname.  */
     return -1;
 
+  /* The hostname is up to the next non-space character.  */
   /* XXX This can cause trouble because the hostname might be too long
      but we have no possibility to check it here.  */
-  memcpy (hostname, line, cp - line);
-  hostname [cp - line] = '\0';
+  while (*line != '\0' && *line != '#' && !isspace (*line))
+    *hostname++ = *line++;
+  *hostname = '\0';
 
   return 0;
 }