[tor-bugs] #7192 [Tor]: parsing exit policy summary drops last character

Tor Bug Tracker & Wiki torproject-admin at torproject.org
Tue Oct 23 13:18:41 UTC 2012


#7192: parsing exit policy summary drops last character
------------------------+---------------------------------------------------
 Reporter:  arma        |          Owner:                    
     Type:  defect      |         Status:  needs_review      
 Priority:  major       |      Milestone:  Tor: 0.2.3.x-final
Component:  Tor         |        Version:  Tor: 0.2.3.23-rc  
 Keywords:  tor-client  |         Parent:                    
   Points:              |   Actualpoints:                    
------------------------+---------------------------------------------------

Comment(by nickm):

 That %c is how you use sscanf to do exact matches rather than prefix
 matches.

 {{{
 #include <stdio.h>
 int main(int argc, char **argv)
 {
   unsigned a,b;
   char dummy;

   /* Here we're using %c: notice how we can tell if there are any extra
      characters after the 1-2 based on the return value. */
   printf("%d\n", sscanf("1-2",  "%u-%u%c", &a, &b, &dummy));
   printf("%d\n", sscanf("1-2x", "%u-%u%c", &a, &b, &dummy));

   /* Here we are not using %c: there isn't a way to tell whether we
    * had extra characters after the 1-2 */
   printf("%d\n", sscanf("1-2", "%u-%u", &a, &b));
   printf("%d\n", sscanf("1-2x", "%u-%u", &a, &b));

   return 0;
 }
 }}}

 Did that answer the question?

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


More information about the tor-bugs mailing list