]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
sendme: Use a simpler and more correct init for sendme tags.
authorNick Mathewson <nickm@torproject.org>
Thu, 5 Jun 2025 19:54:56 +0000 (15:54 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 10 Jun 2025 23:06:47 +0000 (19:06 -0400)
src/core/or/sendme.c

index a02f3a53761cd0649e2362dcc46f0765e7ded64b..77d9518048d05d5a06850351782b4f953f2f3c0f 100644 (file)
@@ -347,9 +347,9 @@ record_cell_digest_on_circ(circuit_t *circ,
   // make sure we don't have heap overflow bugs.
   uint8_t *tag;
   if (tag_len == SHORT_TAG_LEN) {
-    tag = tor_malloc(sizeof(LONG_TAG_LEN));
+    tag = tor_malloc_zero(LONG_TAG_LEN);
     memcpy(tag, sendme_tag, tag_len);
-    memset(tag+SHORT_TAG_LEN, 0, LONG_TAG_LEN - SHORT_TAG_LEN);
+    // (The final bytes were initialized to zero.)
   } else if (tag_len == LONG_TAG_LEN) {
     tag = tor_memdup(sendme_tag, LONG_TAG_LEN);
   } else {