Skip to content

Commit

Permalink
iprep: fix parsing ip-rep data with carriage return
Browse files Browse the repository at this point in the history
Commit e7c0f0a removed uses of atoi with a new number parsing
functions. This broke parsing ip-reputation data files that contained
trailing carriage returns as it was being included in the number
string to convert.

Bug: #6243.
  • Loading branch information
thomasjwinter committed Aug 8, 2023
1 parent 2786ccb commit 3344b71
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/reputation.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ static int SRepSplitLine(SRepCIDRTree *cidr_ctx, char *line, Address *ip, uint8_
char *origline = line;

while (i < (int)line_len) {
if (line[i] == ',' || line[i] == '\n' || line[i] == '\0' || i == (int)(line_len - 1)) {
if (line[i] == ',' || line[i] == '\n' || line[i] == '\r' || line[i] == '\0' ||
i == (int)(line_len - 1)) {
line[i] = '\0';

ptrs[idx] = line;
Expand Down

0 comments on commit 3344b71

Please sign in to comment.