Opened 5 years ago

Closed 5 years ago

#13840 closed defect (fixed)

Refactor? Use END_CIRC_REASON_TORPROTOCOL rather than "1" in connection_exit_begin_conn()

Reported by: arma Owned by:
Priority: Medium Milestone: Tor: 0.2.6.x-final
Component: Core Tor/Tor Version:
Severity: Keywords: tor-relay, easy
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

In the function comment for connection_exit_begin_conn() we see

 * Return -(some circuit end reason) if we want to tear down <b>circ</b>.
 * Else return 0.

and then at the front of the function we see

  if (rh.length > RELAY_PAYLOAD_SIZE)
    return -1;

Now, it happens that 1 is END_CIRC_REASON_TORPROTOCOL, which is a legitimate reason to use in this case. But did we just get lucky?

Later there's also a

  if (r < -1) {
    return -1;

If we want to go wilder with the change here, I think this function actually only ever returns 0 and -1, so it's not actually following the function comment and we could get rid of that part of it instead?

Child Tickets

Change History (5)

comment:1 Changed 5 years ago by arma

Summary: Use END_CIRC_REASON_TORPROTOCOL rather than "1" in connection_exit_begin_conn()Refactor? Use END_CIRC_REASON_TORPROTOCOL rather than "1" in connection_exit_begin_conn()

comment:2 Changed 5 years ago by nickm

Milestone: Tor: unspecifiedTor: 0.2.6.x-final

comment:3 Changed 5 years ago by rl1987

Status: newneeds_review

comment:4 Changed 5 years ago by dgoulet

ACK.

Patch is pretty trivial and looks good. :)

comment:5 Changed 5 years ago by nickm

Resolution: fixed
Status: needs_reviewclosed

Merged. (Thanks for rl1987 for writing and dgoulet for reviewing!)

Note: See TracTickets for help on using tickets.