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

[tor-bugs] #22258 [Core Tor/Tor]: Fix an always-true assert in string parsing



#22258: Fix an always-true assert in string parsing
------------------------------+--------------------------------
     Reporter:  teor          |      Owner:
         Type:  defect        |     Status:  new
     Priority:  Medium        |  Milestone:  Tor: 0.3.1.x-final
    Component:  Core Tor/Tor  |    Version:
     Severity:  Normal        |   Keywords:
Actual Points:                |  Parent ID:
       Points:  0.1           |   Reviewer:
      Sponsor:                |
------------------------------+--------------------------------
 {{{
 const char *err = strchr(cp, ':')+2;
 tor_assert(err);

 The assert would never work. Even if the function strchr returns NULL,
 then the pointer err will store an invalid value ((char *)2), but it won't
 be NULL. It would be correct to write the following:

 const char *err = strchr(cp, ':');
 tor_assert(err);
 err += 2;

 However, as I understand, the function strchr will never return NULL, and
 the check is written just in case.
 }}}

 Reported by Andrey Karpov
 https://www.viva64.com/en/b/0507/

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/22258>
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