summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNeel Chauhan <neel@neelc.org>2020-07-24 18:23:50 -0700
committerNick Mathewson <nickm@torproject.org>2020-07-30 10:46:15 -0400
commit67a62ccf51f46bde75e0675b1ee19c024152f088 (patch)
treec62c1a86300dea0c1aa3767dffad04b47fc3a7bb /src
parentc212578bf05138801597dcce23f52780c9b7dbb3 (diff)
downloadtor-67a62ccf51f46bde75e0675b1ee19c024152f088.tar.gz
tor-67a62ccf51f46bde75e0675b1ee19c024152f088.zip
Use write_str_if_not_equal() for onion services
Diffstat (limited to 'src')
-rw-r--r--src/feature/hs/hs_service.c2
-rw-r--r--src/feature/relay/router.c5
-rw-r--r--src/feature/rend/rendservice.c2
3 files changed, 4 insertions, 5 deletions
diff --git a/src/feature/hs/hs_service.c b/src/feature/hs/hs_service.c
index b56b7f4368..3e264b4686 100644
--- a/src/feature/hs/hs_service.c
+++ b/src/feature/hs/hs_service.c
@@ -990,7 +990,7 @@ write_address_to_file(const hs_service_t *service, const char *fname_)
tor_asprintf(&addr_buf, "%s.%s\n", service->onion_address, address_tld);
/* Notice here that we use the given "fname_". */
fname = hs_path_from_filename(service->config.directory_path, fname_);
- if (write_str_to_file(fname, addr_buf, 0) < 0) {
+ if (write_str_to_file_if_not_equal(fname, addr_buf)) {
log_warn(LD_REND, "Could not write onion address to hostname file %s",
escaped(fname));
goto end;
diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c
index 25263468c8..675b977ade 100644
--- a/src/feature/relay/router.c
+++ b/src/feature/relay/router.c
@@ -835,7 +835,7 @@ router_initialize_tls_context(void)
STATIC int
router_write_fingerprint(int hashed, int ed25519_identity)
{
- char *keydir = NULL, *cp = NULL;
+ char *keydir = NULL;
const char *fname = hashed ? "hashed-fingerprint" :
(ed25519_identity ? "fingerprint-ed25519" :
"fingerprint");
@@ -870,7 +870,7 @@ router_write_fingerprint(int hashed, int ed25519_identity)
tor_asprintf(&fingerprint_line, "%s %s\n", options->Nickname, fingerprint);
/* Check whether we need to write the (hashed-)fingerprint file. */
- if (write_str_if_not_equal(keydir, fingerprint_line)) {
+ if (write_str_to_file_if_not_equal(keydir, fingerprint_line)) {
log_err(LD_FS, "Error writing %s%s line to file",
hashed ? "hashed " : "",
ed25519_identity ? "ed25519 identity" : "fingerprint");
@@ -884,7 +884,6 @@ router_write_fingerprint(int hashed, int ed25519_identity)
result = 0;
done:
- tor_free(cp);
tor_free(keydir);
tor_free(fingerprint_line);
return result;
diff --git a/src/feature/rend/rendservice.c b/src/feature/rend/rendservice.c
index 1ac88d0eb7..8e1a22fb39 100644
--- a/src/feature/rend/rendservice.c
+++ b/src/feature/rend/rendservice.c
@@ -1554,7 +1554,7 @@ rend_service_load_keys(rend_service_t *s)
fname = rend_service_path(s, hostname_fname);
tor_snprintf(buf, sizeof(buf),"%s.onion\n", s->service_id);
- if (write_str_to_file(fname,buf,0)<0) {
+ if (write_str_to_file_if_not_equal(fname, buf)) {
log_warn(LD_CONFIG, "Could not write onion address to hostname file.");
goto err;
}