mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-30 13:57:50 +00:00
Don't write leases that contain non-printable or whitespace characters.
This commit is contained in:
14
server/db.c
14
server/db.c
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"$Id: db.c,v 1.18 1998/03/15 20:46:22 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
"$Id: db.c,v 1.19 1998/08/05 19:32:20 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@@ -61,6 +61,7 @@ int write_lease (lease)
|
|||||||
struct tm *t;
|
struct tm *t;
|
||||||
char tbuf [64];
|
char tbuf [64];
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (counting)
|
if (counting)
|
||||||
++count;
|
++count;
|
||||||
@@ -137,6 +138,10 @@ int write_lease (lease)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lease -> client_hostname) {
|
if (lease -> client_hostname) {
|
||||||
|
for (i = 0; lease -> client_hostname [i]; i++)
|
||||||
|
if (lease -> client_hostname [i] < 33 ||
|
||||||
|
lease -> client_hostname [i] > 126)
|
||||||
|
goto bad_client_hostname;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
fprintf (db_file, "\n\tclient-hostname \"%s\";",
|
fprintf (db_file, "\n\tclient-hostname \"%s\";",
|
||||||
lease -> client_hostname);
|
lease -> client_hostname);
|
||||||
@@ -144,7 +149,13 @@ int write_lease (lease)
|
|||||||
++errors;
|
++errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bad_client_hostname:
|
||||||
if (lease -> hostname) {
|
if (lease -> hostname) {
|
||||||
|
for (i = 0; lease -> hostname [i]; i++)
|
||||||
|
if (lease -> hostname [i] < 33 ||
|
||||||
|
lease -> hostname [i] > 126)
|
||||||
|
goto bad_hostname;
|
||||||
|
errno = 0;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
fprintf (db_file, "\n\thostname \"%s\";",
|
fprintf (db_file, "\n\thostname \"%s\";",
|
||||||
lease -> hostname);
|
lease -> hostname);
|
||||||
@@ -152,6 +163,7 @@ int write_lease (lease)
|
|||||||
++errors;
|
++errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bad_hostname:
|
||||||
errno = 0;
|
errno = 0;
|
||||||
fputs ("\n}\n", db_file);
|
fputs ("\n}\n", db_file);
|
||||||
if (errno) {
|
if (errno) {
|
||||||
|
Reference in New Issue
Block a user