Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#4778 closed defect (fixed)

Bug in timer{add,sub} compatibility functions

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

Description

< Vektor> i have another bugfix for tor
< Vektor> replace:
< Vektor> #define timeradd(tv1,tv2,tvout) \
< Vektor>   do {                                                  \
< Vektor>     (tvout)->tv_sec = (tv1)->tv_sec + (tv2)->tv_sec;    \
< Vektor>     (tvout)->tv_usec = (tv2)->tv_usec + (tv2)->tv_usec; \
< Vektor> with:
< Vektor> #define timeradd(tv1,tv2,tvout) \
< Vektor>   do {                                                  \
< Vektor>     (tvout)->tv_sec = (tv1)->tv_sec + (tv2)->tv_sec;    \
< Vektor>     (tvout)->tv_usec = (tv1)->tv_usec + (tv2)->tv_usec; \
< Vektor> and replace:
< Vektor> #define timersub(tv1,tv2,tvout) \
< Vektor>   do {                                                  \
< Vektor>     (tvout)->tv_sec = (tv1)->tv_sec - (tv2)->tv_sec;    \
< Vektor>     (tvout)->tv_usec = (tv2)->tv_usec - (tv2)->tv_usec; \
< Vektor> with:
< Vektor> #define timersub(tv1,tv2,tvout) \
< Vektor>   do {                                                  \
< Vektor>     (tvout)->tv_sec = (tv1)->tv_sec - (tv2)->tv_sec;    \
< Vektor>     (tvout)->tv_usec = (tv1)->tv_usec - (tv2)->tv_usec; \

These definitions are only used in platforms where timersub and timeradd are not defined.

timeradd doesn't seem to be used anywhere in the code, and timersub only seems to be used in circuit_expire_building().

At first glance, the issue doesn't seem security related, but we should look at it carefully.

Child Tickets

Change History (7)

comment:1 in reply to:  description Changed 8 years ago by arma

Replying to asn:

These definitions are only used in platforms where timersub and timeradd are not defined.

I wonder which platforms these are.

comment:2 Changed 8 years ago by Sebastian

Windows, for example.

comment:3 Changed 8 years ago by Sebastian

Status: newneeds_review

See branch timersub_bug for a patch + changes file

comment:4 Changed 8 years ago by nickm

This looks good to me. One it tests out on my little netbook, I'll merge it to 0.2.2 and master.

comment:5 Changed 8 years ago by nickm

Resolution: fixed
Status: needs_reviewclosed

comment:6 Changed 7 years ago by nickm

Keywords: tor-relay added

comment:7 Changed 7 years ago by nickm

Component: Tor RelayTor
Note: See TracTickets for help on using tickets.