summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Marcher <info@nulltime.net>2016-06-10 18:22:05 +0200
committerAaron Marcher (drkhsh) <info@nulltime.net>2016-06-10 18:22:05 +0200
commitc7f3a407f4f8d539fe68cbf7dde76876cbcbccaa (patch)
tree0b215e97be1de0f02d5291d7bed6bbd0283f53f5
parent2e72b212d3019a23accfd9d001bcec5d3ee5ab46 (diff)
fixed hostname function and added HOST_NAME_MAX limit
-rw-r--r--slstatus.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/slstatus.c b/slstatus.c
index 5bbf58a..404ead6 100644
--- a/slstatus.c
+++ b/slstatus.c
@@ -5,6 +5,7 @@
#include <arpa/inet.h>
#include <fcntl.h>
#include <ifaddrs.h>
+#include <limits.h>
#include <locale.h>
#include <netdb.h>
#include <stdarg.h>
@@ -212,7 +213,7 @@ entropy(const char *null)
char *
hostname(const char *null)
{
- char *hostname = "";
+ char hostname[HOST_NAME_MAX];
FILE *fp;
/* open hostname file */
@@ -222,7 +223,7 @@ hostname(const char *null)
}
/* extract hostname */
- fscanf(fp, "%s", hostname);
+ fscanf(fp, "%s\n", hostname);
/* close hostname file */
fclose(fp);