aboutsummaryrefslogtreecommitdiffstats
path: root/dyndhcpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'dyndhcpd.c')
-rw-r--r--dyndhcpd.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/dyndhcpd.c b/dyndhcpd.c
index 82c20ee..2f62967 100644
--- a/dyndhcpd.c
+++ b/dyndhcpd.c
@@ -1,5 +1,5 @@
/*
- * (C) 2013-2021 by Christian Hesse <mail@eworm.de>
+ * (C) 2013-2024 by Christian Hesse <mail@eworm.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -40,7 +40,7 @@ int replace(char ** config, size_t *length, const char ** tmp,
if (strncmp(template, *tmp, templatelength) == 0) {
*config = realloc(*config, *length + strlen(value) + 1);
- *length += sprintf(*config + *length, value);
+ *length += sprintf(*config + *length, "%s", value);
*tmp += templatelength;
return 1;
}
@@ -57,8 +57,7 @@ int main(int argc, char ** argv) {
char * interface = NULL;
char hostname[HOST_NAME_MAX];
- const char * domainname;
- struct hostent *hp;
+ char * domainname;
char * template = NULL;
FILE * templatefile;
@@ -140,11 +139,11 @@ int main(int argc, char ** argv) {
goto out;
}
- /* get the domainname */
- hp = gethostbyname(hostname);
- if ((domainname = strchr(hp->h_name, '.')) != NULL)
+ /* get the domainname and strip it from hostname */
+ if ((domainname = strchr(hostname, '.')) != NULL) {
+ *domainname = 0;
domainname++;
- else {
+ } else {
fprintf(stderr, "Could not get domainname, using '" FALLBACKDOMAIN "'\n");
domainname = FALLBACKDOMAIN;
}