瀏覽代碼

Use the right functions; strncpy is usually not the answer

Nick Mathewson 11 年之前
父節點
當前提交
aa3c8c1397
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/test/test_nodelist.c

+ 2 - 2
src/test/test_nodelist.c

@@ -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);