* [Qemu-devel] [PATCH] fsdev/virtfs-proxy-helper: Fix possible overflow
@ 2015-03-13 11:09 Shannon Zhao
2015-03-13 12:51 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Shannon Zhao @ 2015-03-13 11:09 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, hangaohuai, qemu-trivial, mjt, peter.huangpeng,
aneesh.kumar, pbonzini, shannon.zhao
It's detected by coverity. As max of sockaddr_un.sun_path is
sizeof(helper.sun_path), should check the length of source
and use strncpy instead of strcpy.
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
fsdev/virtfs-proxy-helper.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
index bf2e5f3..f12d7a0 100644
--- a/fsdev/virtfs-proxy-helper.c
+++ b/fsdev/virtfs-proxy-helper.c
@@ -738,6 +738,7 @@ static int proxy_socket(const char *path, uid_t uid, gid_t gid)
return -1;
}
+ g_assert(strlen(path) < sizeof(proxy.sun_path));
sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
do_perror("socket");
@@ -748,7 +749,7 @@ static int proxy_socket(const char *path, uid_t uid, gid_t gid)
umask(7);
proxy.sun_family = AF_UNIX;
- strcpy(proxy.sun_path, path);
+ strncpy(proxy.sun_path, path, sizeof(proxy.sun_path));
if (bind(sock, (struct sockaddr *)&proxy,
sizeof(struct sockaddr_un)) < 0) {
do_perror("bind");
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] fsdev/virtfs-proxy-helper: Fix possible overflow
2015-03-13 11:09 [Qemu-devel] [PATCH] fsdev/virtfs-proxy-helper: Fix possible overflow Shannon Zhao
@ 2015-03-13 12:51 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2015-03-13 12:51 UTC (permalink / raw)
To: Shannon Zhao, qemu-devel
Cc: peter.maydell, hangaohuai, qemu-trivial, mjt, peter.huangpeng,
aneesh.kumar, shannon.zhao
On 13/03/2015 12:09, Shannon Zhao wrote:
> + g_assert(strlen(path) < sizeof(proxy.sun_path));
> sock = socket(AF_UNIX, SOCK_STREAM, 0);
> if (sock < 0) {
> do_perror("socket");
> @@ -748,7 +749,7 @@ static int proxy_socket(const char *path, uid_t uid, gid_t gid)
> umask(7);
>
> proxy.sun_family = AF_UNIX;
> - strcpy(proxy.sun_path, path);
> + strncpy(proxy.sun_path, path, sizeof(proxy.sun_path));
> if (bind(sock, (struct sockaddr *)&proxy,
Same as the other patch.
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-13 12:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-13 11:09 [Qemu-devel] [PATCH] fsdev/virtfs-proxy-helper: Fix possible overflow Shannon Zhao
2015-03-13 12:51 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).