aboutsummaryrefslogtreecommitdiffstats
path: root/dyndhcpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'dyndhcpd.c')
-rw-r--r--dyndhcpd.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/dyndhcpd.c b/dyndhcpd.c
index e06a4b2..2f62967 100644
--- a/dyndhcpd.c
+++ b/dyndhcpd.c
@@ -1,8 +1,19 @@
/*
- * (C) 2013-2019 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
*
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
*/
#include "dyndhcpd.h"
@@ -29,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;
}
@@ -46,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;
@@ -129,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;
}