tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

ctrl-reply-cleanup.cocci (1052B)


      1 // Script to clean up after ctrl-reply.cocci -- run as a separate step
      2 // because cleanup_write2 (even when disabled) somehow prevents the
      3 // match rule in ctrl-reply.cocci from matching.
      4 
      5 // If it doesn't have to be a printf, turn it into a write
      6 
      7 @ cleanup_write @
      8 expression E;
      9 constant code, s;
     10 @@
     11 -control_printf_endreply(E, code, s)
     12 +control_write_endreply(E, code, s)
     13 
     14 // Use send_control_done() instead of explicitly writing it out
     15 @ cleanup_send_done @
     16 type T;
     17 identifier f != send_control_done;
     18 expression E;
     19 @@
     20  T f(...) {
     21 <...
     22 -control_write_endreply(E, 250, "OK")
     23 +send_control_done(E)
     24  ...>
     25  }
     26 
     27 // Clean up more printfs that could be writes
     28 //
     29 // For some reason, including this rule, even disabled, causes the
     30 // match rule in ctrl-reply.cocci to fail to match some code that has
     31 // %s in its format strings
     32 
     33 @ cleanup_write2 @
     34 expression E1, E2;
     35 constant code;
     36 @@
     37 (
     38 -control_printf_endreply(E1, code, "%s", E2)
     39 +control_write_endreply(E1, code, E2)
     40 |
     41 -control_printf_midreply(E1, code, "%s", E2)
     42 +control_write_midreply(E1, code, E2)
     43 )