]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Use the right functions; strncpy is usually not the answer
authorNick Mathewson <nickm@torproject.org>
Fri, 7 Feb 2014 17:25:49 +0000 (12:25 -0500)
committerNick Mathewson <nickm@torproject.org>
Fri, 7 Feb 2014 17:25:49 +0000 (12:25 -0500)
src/test/test_nodelist.c

index cbdc4a72b5ab42fd41548c61e4e80c6db8fa6844..600e6a89d44005e6c181556228599e81e4e27e6a 100644 (file)
@@ -47,9 +47,9 @@ test_nodelist_node_get_verbose_nickname_not_named(void *arg)
   memset(&mock_rs, 0, sizeof(routerstatus_t));
 
   /* verbose nickname should use ~ instead of = for unnamed routers */
-  strncpy(mock_rs.nickname, "TestOR", 6);
+  strlcpy(mock_rs.nickname, "TestOR", sizeof(mock_rs.nickname));
   mock_node.rs = &mock_rs;
-  strncpy(mock_node.identity,
+  memcpy(mock_node.identity,
           "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA"
           "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA",
           DIGEST_LEN);