summaryrefslogtreecommitdiff
path: root/src/or/routerparse.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-10-27 06:25:29 +0000
committerNick Mathewson <nickm@torproject.org>2004-10-27 06:25:29 +0000
commit06fa8fc05fe36d7154e5c321a080607a21690808 (patch)
tree835cdeb391dfd28b775a79490d1f78677cf82d34 /src/or/routerparse.c
parent4a9c747f6e4bddc7d26e10b8c0a0c510b4e81c47 (diff)
downloadtor-06fa8fc05fe36d7154e5c321a080607a21690808.tar.gz
tor-06fa8fc05fe36d7154e5c321a080607a21690808.zip
Avoid strcat; use snprintf or strlcat instead
svn:r2605
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r--src/or/routerparse.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 6d3ad66506..bc6030b202 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -1032,14 +1032,10 @@ router_parse_exit_policy(directory_token_t *tok) {
newe = tor_malloc_zero(sizeof(struct exit_policy_t));
newe->string = tor_malloc(8+strlen(arg));
- if (tok->tp == K_REJECT) {
- strcpy(newe->string, "reject ");
- newe->policy_type = EXIT_POLICY_REJECT;
- } else {
- strcpy(newe->string, "accept ");
- newe->policy_type = EXIT_POLICY_ACCEPT;
- }
- strcat(newe->string, arg); /* can't overflow */
+ snprintf(newe->string, 8+strlen(arg), "%s %s",
+ (tok->tp == K_REJECT) ? "reject" : "accept", arg);
+ newe->policy_type = (tok->tp == K_REJECT) ? EXIT_POLICY_REJECT
+ : EXIT_POLICY_ACCEPT;
if (parse_addr_and_port_range(arg, &newe->addr, &newe->msk,
&newe->prt_min, &newe->prt_max))