Skip to content

Commit dec51ca

Browse files
committed
remove cr and lf at each line of config files
1 parent 886a6f4 commit dec51ca

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/chinadns.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,11 @@ static int parse_ip_list() {
340340
return -1;
341341
}
342342
while ((line = fgets(line_buf, len, fp))) {
343+
char *sp_pos;
344+
sp_pos = strchr(line, '\r');
345+
if (sp_pos) *sp_pos = 0;
346+
sp_pos = strchr(line, '\n');
347+
if (sp_pos) *sp_pos = 0;
343348
inet_aton(line, &ip_list.ips[i]);
344349
i++;
345350
}
@@ -391,7 +396,12 @@ static int parse_chnroute() {
391396
return -1;
392397
}
393398
while ((line = fgets(line_buf, len, fp))) {
394-
char *sp_pos = strchr(line, '/');
399+
char *sp_pos;
400+
sp_pos = strchr(line, '\r');
401+
if (sp_pos) *sp_pos = 0;
402+
sp_pos = strchr(line, '\n');
403+
if (sp_pos) *sp_pos = 0;
404+
sp_pos = strchr(line, '/');
395405
if (sp_pos) {
396406
*sp_pos = 0;
397407
chnroute_list.nets[i].mask = (1 << (32 - atoi(sp_pos + 1))) - 1;

0 commit comments

Comments
 (0)