Loading src/common/util.c +2 −2 Original line number Diff line number Diff line Loading @@ -5020,7 +5020,7 @@ tor_read_all_handle(FILE *h, char *buf, size_t count, while (numread != count) { /* Use fgets because that is what we use in log_from_pipe() */ retval = fgets(buf+numread, (int)(count-numread), h); retval = tor_fgets(buf+numread, (int)(count-numread), h); if (NULL == retval) { if (feof(h)) { log_debug(LD_GENERAL, "fgets() reached end of file"); Loading Loading @@ -5355,7 +5355,7 @@ get_string_from_pipe(FILE *stream, char *buf_out, size_t count) tor_assert(count <= INT_MAX); retval = fgets(buf_out, (int)count, stream); retval = tor_fgets(buf_out, (int)count, stream); if (!retval) { if (feof(stream)) { Loading src/or/dirserv.c +2 −2 Original line number Diff line number Diff line Loading @@ -2701,7 +2701,7 @@ dirserv_read_measured_bandwidths(const char *from_file, return -1; } if (!fgets(line, sizeof(line), fp) if (!tor_fgets(line, sizeof(line), fp) || !strlen(line) || line[strlen(line)-1] != '\n') { log_warn(LD_DIRSERV, "Long or truncated time in bandwidth file: %s", escaped(line)); Loading Loading @@ -2731,7 +2731,7 @@ dirserv_read_measured_bandwidths(const char *from_file, while (!feof(fp)) { measured_bw_line_t parsed_line; if (fgets(line, sizeof(line), fp) && strlen(line)) { if (tor_fgets(line, sizeof(line), fp) && strlen(line)) { if (measured_bw_line_parse(&parsed_line, line) != -1) { /* Also cache the line for dirserv_get_bandwidth_for_router() */ dirserv_cache_measured_bw(&parsed_line, file_time); Loading src/or/geoip.c +1 −1 Original line number Diff line number Diff line Loading @@ -346,7 +346,7 @@ geoip_load_file(sa_family_t family, const char *filename) (family == AF_INET) ? "IPv4" : "IPv6", filename); while (!feof(f)) { char buf[512]; if (fgets(buf, (int)sizeof(buf), f) == NULL) if (tor_fgets(buf, (int)sizeof(buf), f) == NULL) break; crypto_digest_add_bytes(geoip_digest_env, buf, strlen(buf)); /* FFFF track full country name. */ Loading src/test/test_util.c +9 −9 Original line number Diff line number Diff line Loading @@ -3972,16 +3972,16 @@ test_util_fgets_eagain(void *ptr) /* Send in a partial line */ retlen = write(test_pipe[1], "A", 1); tt_int_op(retlen, OP_EQ, 1); retptr = fgets(buf, sizeof(buf), test_stream); retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, EAGAIN); tt_ptr_op(retptr, OP_EQ, buf); tt_ptr_op(retptr, OP_EQ, NULL); tt_str_op(buf, OP_EQ, "A"); errno = 0; /* Send in the rest */ retlen = write(test_pipe[1], "B\n", 2); tt_int_op(retlen, OP_EQ, 2); retptr = fgets(buf, sizeof(buf), test_stream); retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, 0); tt_ptr_op(retptr, OP_EQ, buf); tt_str_op(buf, OP_EQ, "B\n"); Loading @@ -3990,7 +3990,7 @@ test_util_fgets_eagain(void *ptr) /* Send in a full line */ retlen = write(test_pipe[1], "CD\n", 3); tt_int_op(retlen, OP_EQ, 3); retptr = fgets(buf, sizeof(buf), test_stream); retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, 0); tt_ptr_op(retptr, OP_EQ, buf); tt_str_op(buf, OP_EQ, "CD\n"); Loading @@ -3999,16 +3999,16 @@ test_util_fgets_eagain(void *ptr) /* Send in a partial line */ retlen = write(test_pipe[1], "E", 1); tt_int_op(retlen, OP_EQ, 1); retptr = fgets(buf, sizeof(buf), test_stream); retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, EAGAIN); tt_ptr_op(retptr, OP_EQ, buf); tt_ptr_op(retptr, OP_EQ, NULL); tt_str_op(buf, OP_EQ, "E"); errno = 0; /* Send in the rest */ retlen = write(test_pipe[1], "F\n", 2); tt_int_op(retlen, OP_EQ, 2); retptr = fgets(buf, sizeof(buf), test_stream); retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, 0); tt_ptr_op(retptr, OP_EQ, buf); tt_str_op(buf, OP_EQ, "F\n"); Loading @@ -4020,14 +4020,14 @@ test_util_fgets_eagain(void *ptr) retval = close(test_pipe[1]); tt_int_op(retval, OP_EQ, 0); test_pipe[1] = -1; retptr = fgets(buf, sizeof(buf), test_stream); retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, 0); tt_ptr_op(retptr, OP_EQ, buf); tt_str_op(buf, OP_EQ, "GH"); errno = 0; /* Check for EOF */ retptr = fgets(buf, sizeof(buf), test_stream); retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, 0); tt_ptr_op(retptr, OP_EQ, NULL); retval = feof(test_stream); Loading Loading
src/common/util.c +2 −2 Original line number Diff line number Diff line Loading @@ -5020,7 +5020,7 @@ tor_read_all_handle(FILE *h, char *buf, size_t count, while (numread != count) { /* Use fgets because that is what we use in log_from_pipe() */ retval = fgets(buf+numread, (int)(count-numread), h); retval = tor_fgets(buf+numread, (int)(count-numread), h); if (NULL == retval) { if (feof(h)) { log_debug(LD_GENERAL, "fgets() reached end of file"); Loading Loading @@ -5355,7 +5355,7 @@ get_string_from_pipe(FILE *stream, char *buf_out, size_t count) tor_assert(count <= INT_MAX); retval = fgets(buf_out, (int)count, stream); retval = tor_fgets(buf_out, (int)count, stream); if (!retval) { if (feof(stream)) { Loading
src/or/dirserv.c +2 −2 Original line number Diff line number Diff line Loading @@ -2701,7 +2701,7 @@ dirserv_read_measured_bandwidths(const char *from_file, return -1; } if (!fgets(line, sizeof(line), fp) if (!tor_fgets(line, sizeof(line), fp) || !strlen(line) || line[strlen(line)-1] != '\n') { log_warn(LD_DIRSERV, "Long or truncated time in bandwidth file: %s", escaped(line)); Loading Loading @@ -2731,7 +2731,7 @@ dirserv_read_measured_bandwidths(const char *from_file, while (!feof(fp)) { measured_bw_line_t parsed_line; if (fgets(line, sizeof(line), fp) && strlen(line)) { if (tor_fgets(line, sizeof(line), fp) && strlen(line)) { if (measured_bw_line_parse(&parsed_line, line) != -1) { /* Also cache the line for dirserv_get_bandwidth_for_router() */ dirserv_cache_measured_bw(&parsed_line, file_time); Loading
src/or/geoip.c +1 −1 Original line number Diff line number Diff line Loading @@ -346,7 +346,7 @@ geoip_load_file(sa_family_t family, const char *filename) (family == AF_INET) ? "IPv4" : "IPv6", filename); while (!feof(f)) { char buf[512]; if (fgets(buf, (int)sizeof(buf), f) == NULL) if (tor_fgets(buf, (int)sizeof(buf), f) == NULL) break; crypto_digest_add_bytes(geoip_digest_env, buf, strlen(buf)); /* FFFF track full country name. */ Loading
src/test/test_util.c +9 −9 Original line number Diff line number Diff line Loading @@ -3972,16 +3972,16 @@ test_util_fgets_eagain(void *ptr) /* Send in a partial line */ retlen = write(test_pipe[1], "A", 1); tt_int_op(retlen, OP_EQ, 1); retptr = fgets(buf, sizeof(buf), test_stream); retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, EAGAIN); tt_ptr_op(retptr, OP_EQ, buf); tt_ptr_op(retptr, OP_EQ, NULL); tt_str_op(buf, OP_EQ, "A"); errno = 0; /* Send in the rest */ retlen = write(test_pipe[1], "B\n", 2); tt_int_op(retlen, OP_EQ, 2); retptr = fgets(buf, sizeof(buf), test_stream); retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, 0); tt_ptr_op(retptr, OP_EQ, buf); tt_str_op(buf, OP_EQ, "B\n"); Loading @@ -3990,7 +3990,7 @@ test_util_fgets_eagain(void *ptr) /* Send in a full line */ retlen = write(test_pipe[1], "CD\n", 3); tt_int_op(retlen, OP_EQ, 3); retptr = fgets(buf, sizeof(buf), test_stream); retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, 0); tt_ptr_op(retptr, OP_EQ, buf); tt_str_op(buf, OP_EQ, "CD\n"); Loading @@ -3999,16 +3999,16 @@ test_util_fgets_eagain(void *ptr) /* Send in a partial line */ retlen = write(test_pipe[1], "E", 1); tt_int_op(retlen, OP_EQ, 1); retptr = fgets(buf, sizeof(buf), test_stream); retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, EAGAIN); tt_ptr_op(retptr, OP_EQ, buf); tt_ptr_op(retptr, OP_EQ, NULL); tt_str_op(buf, OP_EQ, "E"); errno = 0; /* Send in the rest */ retlen = write(test_pipe[1], "F\n", 2); tt_int_op(retlen, OP_EQ, 2); retptr = fgets(buf, sizeof(buf), test_stream); retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, 0); tt_ptr_op(retptr, OP_EQ, buf); tt_str_op(buf, OP_EQ, "F\n"); Loading @@ -4020,14 +4020,14 @@ test_util_fgets_eagain(void *ptr) retval = close(test_pipe[1]); tt_int_op(retval, OP_EQ, 0); test_pipe[1] = -1; retptr = fgets(buf, sizeof(buf), test_stream); retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, 0); tt_ptr_op(retptr, OP_EQ, buf); tt_str_op(buf, OP_EQ, "GH"); errno = 0; /* Check for EOF */ retptr = fgets(buf, sizeof(buf), test_stream); retptr = tor_fgets(buf, sizeof(buf), test_stream); tt_int_op(errno, OP_EQ, 0); tt_ptr_op(retptr, OP_EQ, NULL); retval = feof(test_stream); Loading