]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Avoid unsigned integer underflow on empty input.
authorNick Mathewson <nickm@torproject.org>
Mon, 7 May 2018 17:56:39 +0000 (13:56 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 8 May 2018 18:24:29 +0000 (14:24 -0400)
src/or/dirserv.c

index d9a9b8522db392364e17f2f4665b64d650383646..e47533759b6ac3efb16725846a1fbae797a6c43e 100644 (file)
@@ -2641,6 +2641,12 @@ measured_bw_line_parse(measured_bw_line_t *out, const char *orig_line)
   int got_node_id = 0;
   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 */
   if (line[strlen(line) - 1] == '\n') {
     line[strlen(line) - 1] = '\0';