Browse Source

fix the issue introduced by newline

pull/77/head
Max Lv 10 years ago
parent
commit
e29b755c6d
1 changed files with 9 additions and 0 deletions
  1. 9
      src/acl.c

9
src/acl.c

@ -10,6 +10,7 @@ static void parse_addr_cidr(const char *str, char **host, int *cidr)
{
int ret = -1, n = 0;
char *pch;
pch = strchr(str, '/');
while (pch != NULL)
{
@ -53,6 +54,13 @@ int init_acl(const char *path)
{
if (fgets(line, 256, f))
{
// Trim the newline
int len = strlen(line);
if (len > 0 && line[len - 1] == '\n')
{
line[len - 1] = '\0';
}
char *host = NULL;
int cidr;
parse_addr_cidr(line, &host, &cidr);
@ -111,6 +119,7 @@ int acl_contains_domain(const char* domain)
if (match) return 1;
}
return 0;
}

Loading…
Cancel
Save