Skip to content

Commit

Permalink
allow hostnames in blacklist up to 255 bytes (#526)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinbastress committed Jun 6, 2018
1 parent 84a23a2 commit 0e94a7c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/blacklist.c
Expand Up @@ -104,7 +104,7 @@ void whitelist_prefix(char *ip, int prefix_len)

static int init_from_string(char *ip, int value)
{
int prefix_len = 32;
int prefix_len = 256;
char *slash = strchr(ip, '/');
if (slash) { // split apart network and prefix length
*slash = '\0';
Expand All @@ -113,7 +113,7 @@ static int init_from_string(char *ip, int value)
errno = 0;
prefix_len = strtol(len, &end, 10);
if (end == len || errno != 0 || prefix_len < 0 ||
prefix_len > 32) {
prefix_len > 256) {
log_fatal("constraint",
"'%s' is not a valid prefix length", len);
return -1;
Expand Down Expand Up @@ -171,8 +171,9 @@ static int init_from_file(char *file, const char *name, int value,
if (comment) {
*comment = '\0';
}
char ip[33];
if ((sscanf(line, "%32s", ip)) == EOF) {
// hostnames can be up to 255 bytes
char ip[256];
if ((sscanf(line, "%256s", ip)) == EOF) {
continue;
}
if (init_from_string(ip, value)) {
Expand Down

0 comments on commit 0e94a7c

Please sign in to comment.