summaryrefslogtreecommitdiff
path: root/src/common/util.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-06-28 11:49:27 -0400
committerNick Mathewson <nickm@torproject.org>2018-06-28 11:49:27 -0400
commit8c6ff9fec2ed8b1eed6a4c35370f62f1bf24a158 (patch)
tree89961c10a056b65cf1e92d785d9156c038c1defe /src/common/util.c
parent30166261bb1e523db1199ea422c9bf09f30de69f (diff)
downloadtor-8c6ff9fec2ed8b1eed6a4c35370f62f1bf24a158.tar.gz
tor-8c6ff9fec2ed8b1eed6a4c35370f62f1bf24a158.zip
Move tor_escape_str_for_pt_args into or/transports.c
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c37
1 files changed, 0 insertions, 37 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 5a104d39f1..6a557c9560 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -225,43 +225,6 @@ add_laplace_noise(int64_t signal_, double random_, double delta_f,
* String manipulation
* ===== */
-/** Return a newly allocated string equal to <b>string</b>, except that every
- * character in <b>chars_to_escape</b> is preceded by a backslash. */
-char *
-tor_escape_str_for_pt_args(const char *string, const char *chars_to_escape)
-{
- char *new_string = NULL;
- char *new_cp = NULL;
- size_t length, new_length;
-
- tor_assert(string);
-
- length = strlen(string);
-
- if (!length) /* If we were given the empty string, return the same. */
- return tor_strdup("");
- /* (new_length > SIZE_MAX) => ((length * 2) + 1 > SIZE_MAX) =>
- (length*2 > SIZE_MAX - 1) => (length > (SIZE_MAX - 1)/2) */
- if (length > (SIZE_MAX - 1)/2) /* check for overflow */
- return NULL;
-
- /* this should be enough even if all characters must be escaped */
- new_length = (length * 2) + 1;
-
- new_string = new_cp = tor_malloc(new_length);
-
- while (*string) {
- if (strchr(chars_to_escape, *string))
- *new_cp++ = '\\';
-
- *new_cp++ = *string++;
- }
-
- *new_cp = '\0'; /* NUL-terminate the new string */
-
- return new_string;
-}
-
/* =====
* Time
* ===== */