]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Actually, bail out of routerstatus_format_entry() if fmt_addr32() fails
authorrl1987 <rl1987@sdf.lonestar.org>
Wed, 8 Apr 2020 16:54:47 +0000 (19:54 +0300)
committerrl1987 <rl1987@users.noreply.github.com>
Thu, 21 May 2020 10:43:41 +0000 (13:43 +0300)
src/feature/nodelist/fmt_routerstatus.c

index 6cecbf4df8d3e433ee9c1e4fb69ea28691b2c350..ca4a312639ede9092a63acde15a4ec5c6d07780f 100644 (file)
@@ -54,22 +54,23 @@ routerstatus_format_entry(const routerstatus_t *rs, const char *version,
   smartlist_t *chunks = smartlist_new();
 
   const char *ip_str = fmt_addr32(rs->addr);
+  if (ip_str[0] == '\0')
+    goto err;
 
   format_iso_time(published, rs->published_on);
   digest_to_base64(identity64, rs->identity_digest);
   digest_to_base64(digest64, rs->descriptor_digest);
 
-  if (ip_str[0])
-    smartlist_add_asprintf(chunks,
-                     "r %s %s %s%s%s %s %d %d\n",
-                     rs->nickname,
-                     identity64,
-                     (format==NS_V3_CONSENSUS_MICRODESC)?"":digest64,
-                     (format==NS_V3_CONSENSUS_MICRODESC)?"":" ",
-                     published,
-                     ip_str,
-                     (int)rs->or_port,
-                     (int)rs->dir_port);
+  smartlist_add_asprintf(chunks,
+                   "r %s %s %s%s%s %s %d %d\n",
+                   rs->nickname,
+                   identity64,
+                   (format==NS_V3_CONSENSUS_MICRODESC)?"":digest64,
+                   (format==NS_V3_CONSENSUS_MICRODESC)?"":" ",
+                   published,
+                   ip_str,
+                   (int)rs->or_port,
+                   (int)rs->dir_port);
 
   /* TODO: Maybe we want to pass in what we need to build the rest of
    * this here, instead of in the caller. Then we could use the