[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [tor-bugs] #21654 [Core Tor/Tor]: Don't use fgets() when we might get EAGAIN



#21654: Don't use fgets() when we might get EAGAIN
--------------------------+------------------------------------
 Reporter:  nickm         |          Owner:  ahf
     Type:  defect        |         Status:  needs_review
 Priority:  Medium        |      Milestone:  Tor: 0.3.1.x-final
Component:  Core Tor/Tor  |        Version:
 Severity:  Normal        |     Resolution:
 Keywords:                |  Actual Points:
Parent ID:                |         Points:
 Reviewer:                |        Sponsor:
--------------------------+------------------------------------
Changes (by ahf):

 * status:  needs_revision => needs_review


Comment:

 I've updated my branch again.

 1. Fixed by setting `buf[ret] = '\0'` in the `else`-branch in
 `get_string_from_pipe()`.
 2. Removed the code that did that - was an artifact from the `fgets(3)`
 implementation.
 3. This is done in a separate commit for the 3 places in the utility
 module that uses `while (numread != count)` instead of `while (numread <
 count)`:
 https://gitlab.com/ahf/tor/commit/02ef06516e64c1559b24123d7c7d164b76110c9a
 4. Added changes file.
 5. Protected the implementation within an `#ifndef _WIN32`/`#endif` block
 and marked the test with `UTIL_TEST_NO_WIN()`.

 Additionally I've added a patch that removes the `tor_fgets()` wrapper
 since this is no longer needed. The only places left in the code that
 calls `fgets(3)` is in dirserv and the geoip module - both places where it
 should be safe to use `fgets(3)` directly. The test-case for the very
 specific `EAGAIN` checks in `fgets(3)` have been removed in the same
 commit.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/21654#comment:11>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs