Skip to content
Snippets Groups Projects
  1. Sep 27, 2017
  2. Sep 05, 2017
    • Nick Mathewson's avatar
      Refactor buffer APIs to put a buf_t first. · 6ec50597
      Nick Mathewson authored
      By convention, a function that frobs a foo_t should be called
      foo_frob, and it should have a foo_t * as its first argument.  But
      for many of the buf_t functions, the buf_t was the final argument,
      which is silly.
      6ec50597
    • Nick Mathewson's avatar
      Repair buffer API so everything starts with buf_. · 4a7e90ad
      Nick Mathewson authored
      Our convention is that functions which manipulate a type T should be
      named T_foo.  But the buffer functions were super old, and followed
      all kinds of conventions.  Now they're uniform.
      
      Here's the perl I used to do this:
      
      \#!/usr/bin/perl -w -i -p
      
      s/read_to_buf\(/buf_read_from_socket\(/;
      s/flush_buf\(/buf_flush_to_socket\(/;
      s/read_to_buf_tls\(/buf_read_from_tls\(/;
      s/flush_buf_tls\(/buf_flush_to_tls\(/;
      s/write_to_buf\(/buf_add\(/;
      s/write_to_buf_compress\(/buf_add_compress\(/;
      s/move_buf_to_buf\(/buf_move_to_buf\(/;
      s/peek_from_buf\(/buf_peek\(/;
      s/fetch_from_buf\(/buf_get_bytes\(/;
      s/fetch_from_buf_line\(/buf_get_line\(/;
      s/fetch_from_buf_line\(/buf_get_line\(/;
      s/buf_remove_from_front\(/buf_drain\(/;
      s/peek_buf_startswith\(/buf_peek_startswith\(/;
      s/assert_buf_ok\(/buf_assert_ok\(/;
      4a7e90ad
    • Nick Mathewson's avatar
      Move protocol-specific functions out of buffers.c · 234c5015
      Nick Mathewson authored
      This commit does not change the implementation of any function: it
      only moves code and adds new includes as necessary.  Part of #23149.
      234c5015
  3. Aug 24, 2017
  4. Jun 22, 2017
  5. Jun 04, 2017
  6. Mar 15, 2017
  7. Jun 11, 2016
    • Nick Mathewson's avatar
      Add -Wmissing-variable-declarations, with attendant fixes · 53a3b39d
      Nick Mathewson authored
      This is a big-ish patch, but it's very straightforward.  Under this
      clang warning, we're not actually allowed to have a global variable
      without a previous extern declaration for it.  The cases where we
      violated this rule fall into three roughly equal groups:
        * Stuff that should have been static.
        * Stuff that was global but where the extern was local to some
          other C file.
        * Stuff that was only global when built for the unit tests, that
          needed a conditional extern in the headers.
      
      The first two were IMO genuine problems; the last is a wart of how
      we build tests.
      53a3b39d
  8. Feb 27, 2016
  9. Jan 02, 2015
  10. Nov 12, 2014
  11. Nov 04, 2014
  12. Oct 28, 2014
  13. Oct 22, 2014
  14. Oct 01, 2014
    • Yawning Angel's avatar
      Send back SOCKS5 errors for all of the address related failures. · c8132aab
      Yawning Angel authored
      Cases that now send errors:
       * Malformed IP address (SOCKS5_GENERAL_ERROR)
       * CONNECT/RESOLVE request with IP, when SafeSocks is set
         (SOCKS5_NOT_ALLOWED)
       * RESOLVE_PTR request with FQDN (SOCKS5_ADDRESS_TYPE_NOT_SUPPORTED)
       * Malformed FQDN (SOCKS5_GENERAL_ERROR)
       * Unknown address type (SOCKS5_ADDRESS_TYPE_NOT_SUPPORTED)
      
      Fixes bug 13314.
      c8132aab
  15. Sep 29, 2014
  16. Sep 16, 2014
    • Nick Mathewson's avatar
      Use coccinelle scripts to clean up our unit tests · 02438957
      Nick Mathewson authored
      This should get rid of most of the users of the old test_*
      functions.  Some are in macros and will need manual cleanup, though.
      
      This patch is for 13119, and was automatically generated with these
      scripts.  The perl scripts are there because coccinelle hates
      operators as macro arguments.
      
      ------------------------------
      
      s/==,/_X_EQ_,/g;
      s/!=,/_X_NE_,/g;
      s/<,/_X_LT_,/g;
      s/>,/_X_GT_,/g;
      s/>=,/_X_GEQ_,/g;
      s/<=,/_X_LEQ_,/g;
      
      ------------------------------
      @@
      expression a;
      identifier func;
      @@
       func (...) {
      <...
      -test_fail_msg
      +TT_DIE
       (
      +(
       a
      +)
       )
       ...>
       }
      
      @@
      identifier func;
      @@
       func (...) {
      <...
      -test_fail()
      +TT_DIE(("Assertion failed."))
       ...>
       }
      
      @@
      expression a;
      identifier func;
      @@
       func (...) {
      <...
      -test_assert
      +tt_assert
      	(a)
       ...>
       }
      
      @@
      expression a, b;
      identifier func;
      @@
       func (...) {
      <...
      -test_eq
      +tt_int_op
       (a,
      +_X_EQ_,
        b)
       ...>
       }
      
      @@
      expression a, b;
      identifier func;
      @@
       func (...) {
      <...
      -test_neq
      +tt_int_op
       (a,
      +_X_NEQ_,
        b)
       ...>
       }
      
      @@
      expression a, b;
      identifier func;
      @@
       func (...) {
      <...
      -test_streq
      +tt_str_op
       (a,
      +_X_EQ_,
        b)
       ...>
       }
      
      @@
      expression a, b;
      identifier func;
      @@
       func (...) {
      <...
      -test_strneq
      +tt_str_op
       (a,
      +_X_NEQ_,
        b)
       ...>
       }
      
      @@
      expression a, b;
      identifier func;
      @@
       func (...) {
      <...
      -test_eq_ptr
      +tt_ptr_op
       (a,
      +_X_EQ_,
        b)
       ...>
       }
      
      @@
      expression a, b;
      identifier func;
      @@
       func() {
      <...
      -test_neq_ptr
      +tt_ptr_op
       (a,
      +_X_NEQ_,
        b)
       ...>
       }
      
      @@
      expression a, b, len;
      identifier func;
      @@
       func (...) {
      <...
      -test_memeq
      +tt_mem_op
       (a,
      +_X_EQ_,
        b, len)
       ...>
       }
      
      @@
      expression a, b, len;
      identifier func;
      @@
       func (...) {
      <...
      -test_memneq
      +tt_mem_op
       (a,
      +_X_NEQ_,
        b, len)
       ...>
       }
      
      ------------------------------
      @@
      char a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a == b
      +a, _X_EQ_, b
       )
       ...>
      }
      
      @@
      int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a == b
      +a, _X_EQ_, b
       )
       ...>
      }
      
      @@
      long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a == b
      +a, _X_EQ_, b
       )
       ...>
      }
      
      @@
      unsigned int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a == b
      +a, _X_EQ_, b
       )
       ...>
      }
      
      @@
      unsigned long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a == b
      +a, _X_EQ_, b
       )
       ...>
      }
      
      @@
      char a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a != b
      +a, _X_NEQ_, b
       )
       ...>
      }
      
      @@
      int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a != b
      +a, _X_NEQ_, b
       )
       ...>
      }
      
      @@
      long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a != b
      +a, _X_NEQ_, b
       )
       ...>
      }
      
      @@
      unsigned int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a != b
      +a, _X_NEQ_, b
       )
       ...>
      }
      
      @@
      unsigned long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a != b
      +a, _X_NEQ_, b
       )
       ...>
      }
      
      @@
      char a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a >= b
      +a, _X_GEQ_, b
       )
       ...>
      }
      
      @@
      int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a >= b
      +a, _X_GEQ_, b
       )
       ...>
      }
      
      @@
      long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a >= b
      +a, _X_GEQ_, b
       )
       ...>
      }
      
      @@
      unsigned int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a >= b
      +a, _X_GEQ_, b
       )
       ...>
      }
      
      @@
      unsigned long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a >= b
      +a, _X_GEQ_, b
       )
       ...>
      }
      
      @@
      char a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a <= b
      +a, _X_LEQ_, b
       )
       ...>
      }
      
      @@
      int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a <= b
      +a, _X_LEQ_, b
       )
       ...>
      }
      
      @@
      long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a <= b
      +a, _X_LEQ_, b
       )
       ...>
      }
      
      @@
      unsigned int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a <= b
      +a, _X_LEQ_, b
       )
       ...>
      }
      
      @@
      unsigned long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a <= b
      +a, _X_LEQ_, b
       )
       ...>
      }
      
      @@
      char a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a > b
      +a, _X_GT_, b
       )
       ...>
      }
      
      @@
      int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a > b
      +a, _X_GT_, b
       )
       ...>
      }
      
      @@
      long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a > b
      +a, _X_GT_, b
       )
       ...>
      }
      
      @@
      unsigned int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a > b
      +a, _X_GT_, b
       )
       ...>
      }
      
      @@
      unsigned long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a > b
      +a, _X_GT_, b
       )
       ...>
      }
      
      @@
      char a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a < b
      +a, _X_LT_, b
       )
       ...>
      }
      
      @@
      int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a < b
      +a, _X_LT_, b
       )
       ...>
      }
      
      @@
      long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a < b
      +a, _X_LT_, b
       )
       ...>
      }
      
      @@
      unsigned int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a < b
      +a, _X_LT_, b
       )
       ...>
      }
      
      @@
      unsigned long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a < b
      +a, _X_LT_, b
       )
       ...>
      }
      
      ------------------------------
      
      s/_X_NEQ_/!=/g;
      s/_X_NE_/!=/g;
      s/_X_EQ_/==/g;
      s/_X_GT_/>/g;
      s/_X_LT_/</g;
      s/_X_GEQ_/>=/g;
      s/_X_LEQ_/<=/g;
      
      s/test_mem_op\(/tt_mem_op\(/g;
      02438957
  17. Aug 15, 2013
Loading