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

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



#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
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs