Commit 29b3dd1c authored by George Kadianakis's avatar George Kadianakis Committed by Nick Mathewson
Browse files

Fix 32-bit bug when writing address to descriptor.

We used to sizeof() a pointer. Let's just use asprintf to avoid having
to be smart.
parent 434112df
......@@ -62,9 +62,9 @@
/* Onion service directory file names. */
static const char *fname_keyfile_prefix = "hs_ed25519";
static const char *fname_hostname = "hostname";
static const char *address_tld = "onion";
static const char fname_keyfile_prefix[] = "hs_ed25519";
static const char fname_hostname[] = "hostname";
static const char address_tld[] = "onion";
/* Staging list of service object. When configuring service, we add them to
* this list considered a staging area and they will get added to our global
......@@ -817,20 +817,17 @@ write_address_to_file(const hs_service_t *service, const char *fname_)
int ret = -1;
char *fname = NULL;
/* Length of an address plus the sizeof the address tld (onion) which counts
* the NUL terminated byte so we keep it for the "." and the newline. */
char buf[HS_SERVICE_ADDR_LEN_BASE32 + sizeof(address_tld) + 1];
char *addr_buf = NULL;
/* Construct the full address with the onion tld and write the hostname file
* to disk. */
tor_snprintf(buf, sizeof(buf), "%s.%s\n", service->onion_address,
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, buf, 0) < 0) {
if (write_str_to_file(fname, addr_buf, 0) < 0) {
log_warn(LD_REND, "Could not write onion address to hostname file %s",
goto end;
......@@ -850,6 +847,7 @@ write_address_to_file(const hs_service_t *service, const char *fname_)
ret = 0;
return ret;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment