提交 9d055d8a 编写于 作者: J Jim Meyering 提交者: Anthony Liguori

vscsi: avoid unwarranted strncpy

Don't use strncpy when the source string is known to fit
in the destination buffer.  Use equivalent memcpy.
We could even use strcpy, here, but some static analyzers
warn about that, so don't add new uses.
Acked-by: NDavid Gibson <david@gibson.dropbear.id.au>
Signed-off-by: NJim Meyering <meyering@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 9238c209
...@@ -737,7 +737,7 @@ static int vscsi_send_adapter_info(VSCSIState *s, vscsi_req *req) ...@@ -737,7 +737,7 @@ static int vscsi_send_adapter_info(VSCSIState *s, vscsi_req *req)
#endif #endif
memset(&info, 0, sizeof(info)); memset(&info, 0, sizeof(info));
strcpy(info.srp_version, SRP_VERSION); strcpy(info.srp_version, SRP_VERSION);
strncpy(info.partition_name, "qemu", sizeof("qemu")); memcpy(info.partition_name, "qemu", sizeof("qemu"));
info.partition_number = cpu_to_be32(0); info.partition_number = cpu_to_be32(0);
info.mad_version = cpu_to_be32(1); info.mad_version = cpu_to_be32(1);
info.os_type = cpu_to_be32(2); info.os_type = cpu_to_be32(2);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册