mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-24 00:54:02 +00:00
fix the issue introduced by newline
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user