commit de7198ec54f6d63fdb994a0cb140dff8d5208192
parent 4a58af8d572aaede8782c2eb0599bd020eca9c42
Author: Naveen Narayanan <zerous@nocebo.space>
Date: Sun, 10 Oct 2021 03:53:11 +0200
Fix bug in parser.c
Truncate str, returned by gethostname,
to hostname from FQDN.
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/parser.c b/parser.c
@@ -184,12 +184,18 @@ static int
hostname()
{
char str[MAXHOSTNAMELEN];
+ char *sp;
if (gethostname(str, MAXHOSTNAMELEN) == -1)
return 0;
if (!word())
return 0;
+
+ /* truncate str to hostname from FQDN */
+ sp = strchr(str, '.');
+ if (sp)
+ *sp = '\0';
if (strcmp(token, str))
return 0;