diff options
author | Arthur Edelstein <arthuredelstein@gmail.com> | 2014-07-15 21:27:59 -0700 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-01-28 12:02:15 -0500 |
commit | cb714d896c4436f80bca9e82fc978a245d802eb3 (patch) | |
tree | a9840a033370a1bb3c35c93eaded1114855db84b /src/common/util.c | |
parent | f75ca04520f9494e10ea8c4a5de584270efa3462 (diff) | |
download | tor-cb714d896c4436f80bca9e82fc978a245d802eb3.tar.gz tor-cb714d896c4436f80bca9e82fc978a245d802eb3.zip |
Bug #8405: Report SOCKS username/password in CIRC status events
Introduces two new circuit status name-value parameters: SOCKS_USERNAME
and SOCKS_PASSWORD. Values are enclosing in quotes and unusual characters
are escaped.
Example:
650 CIRC 5 EXTENDED [...] SOCKS_USERNAME="my_username" SOCKS_PASSWORD="my_password"
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c index be866a5fe6..442d57a2cf 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -1381,6 +1381,20 @@ esc_for_log(const char *s) return result; } +/** Similar to esc_for_log. Allocate and return a new string representing + * the first n characters in <b>chars</b>, surround by quotes and using + * standard C escapes. If a NUL character is encountered in <b>chars</b>, + * the resulting string will be terminated there. + */ +char * +esc_for_log_len(const char *chars, size_t n) +{ + char *string = tor_strndup(chars, n); + char *string_escaped = esc_for_log(string); + tor_free(string); + return string_escaped; +} + /** Allocate and return a new string representing the contents of <b>s</b>, * surrounded by quotes and using standard C escapes. * |