]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix spurious compiler warning in do_getpass().
authorNick Mathewson <nickm@torproject.org>
Tue, 11 Oct 2016 13:34:08 +0000 (09:34 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 11 Oct 2016 13:34:08 +0000 (09:34 -0400)
Some compilers apparently noticed that p2len was allowed to be equal
to msg, and so maybe we would be doing memset(prompt2, ' ', 0), and
decided that we probably meant to do memset(prompt2, 0, 0x20);
instead.

Stupid compilers, doing optimization before this kind of warning!

My fix is to just fill the entire prompt2 buffer with spaces,
because it's harmless.

Bugfix on e59f0d4cb964387c5, not in any released Tor.

src/or/routerkeys.c

index d5e7051296734eb43e4f8c9561fecf912a95c7e5..ca32228fc7815e5d2b0a104449c799d409e510ef 100644 (file)
@@ -49,7 +49,7 @@ do_getpass(const char *prompt, char *buf, size_t buflen,
     if (p2len < sizeof(msg))
       p2len = sizeof(msg);
     prompt2 = tor_malloc(p2len);
-    memset(prompt2, ' ', p2len - sizeof(msg));
+    memset(prompt2, ' ', p2len);
     memcpy(prompt2 + p2len - sizeof(msg), msg, sizeof(msg));
 
     buf2 = tor_malloc_zero(buflen);