Skip to content
Snippets Groups Projects
Commit a17dc087 authored by Nick Mathewson's avatar Nick Mathewson :game_die:
Browse files

Avoid unsigned integer underflow on empty input.

parent dbc80ad1
No related branches found
No related tags found
No related merge requests found
...@@ -2641,6 +2641,12 @@ measured_bw_line_parse(measured_bw_line_t *out, const char *orig_line) ...@@ -2641,6 +2641,12 @@ measured_bw_line_parse(measured_bw_line_t *out, const char *orig_line)
int got_node_id = 0; int got_node_id = 0;
char *strtok_state; /* lame sauce d'jour */ char *strtok_state; /* lame sauce d'jour */
if (strlen(line) == 0) {
log_warn(LD_DIRSERV, "Empty line in bandwidth file");
tor_free(line);
return -1;
}
/* Remove end of line character, so that is not part of the token */ /* Remove end of line character, so that is not part of the token */
if (line[strlen(line) - 1] == '\n') { if (line[strlen(line) - 1] == '\n') {
line[strlen(line) - 1] = '\0'; line[strlen(line) - 1] = '\0';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment