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

Tor Bug Tracker & Wiki blackhole at torproject.org
Wed Mar 8 17:57:47 UTC 2017


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

 * status:  needs_review => needs_revision


Comment:

 Closer and closer!

   * The string that goes into 'buf' in get_string_from_pipe() is not
 actually nul-terminated.  The current code only sets a nul there when the
 last character read is a newline.
   * It doesn't make sense to me to return EAGAIN when the buffer starts
 with a NUL.  If we read a NUL, then we read a NUL -- tat's all it means.
   * I'd suggest that we change tor_read_all_handle to do "while numread <
 count", so that if we have some bug that makes it go over count, we don't
 keep reading forever.
   * This will need a changes file.
   * This pipe() test needs to be made non-Windows-only: Windows doesn't
 have a pipe().

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/21654#comment:9>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list