* [Qemu-devel] [PATCH v2] sockets: avoid formatting buffer that may not be NUL terminated
@ 2017-06-26 10:37 Daniel P. Berrange
2017-06-26 10:42 ` Peter Maydell
2017-06-27 13:05 ` Michael Tokarev
0 siblings, 2 replies; 3+ messages in thread
From: Daniel P. Berrange @ 2017-06-26 10:37 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-trivial, Peter Maydell, Gerd Hoffmann, Paolo Bonzini,
Thomas Huth, Daniel P. Berrange
The 'sun_path' field in the sockaddr_un struct is not required
to be NUL termianted, so when reporting an error, we must use
the separate 'path' variable which is guaranteed terminated.
Fixes a bug spotted by coverity that was introduced in
commit ad9579aaa16d5b385922d49edac2c96c79bcfb62
Author: Daniel P. Berrange <berrange@redhat.com>
Date: Thu May 25 16:53:00 2017 +0100
sockets: improve error reporting if UNIX socket path is too long
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
util/qemu-sockets.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 51bf279..37d386f 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -930,7 +930,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr,
strncpy(un.sun_path, path, sizeof(un.sun_path));
if (bind(sock, (struct sockaddr*) &un, sizeof(un)) < 0) {
- error_setg_errno(errp, errno, "Failed to bind socket to %s", un.sun_path);
+ error_setg_errno(errp, errno, "Failed to bind socket to %s", path);
goto err;
}
if (listen(sock, 1) < 0) {
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [Qemu-devel] [PATCH v2] sockets: avoid formatting buffer that may not be NUL terminated
2017-06-26 10:37 [Qemu-devel] [PATCH v2] sockets: avoid formatting buffer that may not be NUL terminated Daniel P. Berrange
@ 2017-06-26 10:42 ` Peter Maydell
2017-06-27 13:05 ` Michael Tokarev
1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2017-06-26 10:42 UTC (permalink / raw)
To: Daniel P. Berrange
Cc: QEMU Developers, QEMU Trivial, Gerd Hoffmann, Paolo Bonzini,
Thomas Huth
On 26 June 2017 at 11:37, Daniel P. Berrange <berrange@redhat.com> wrote:
> The 'sun_path' field in the sockaddr_un struct is not required
> to be NUL termianted, so when reporting an error, we must use
"terminated", but hopefully whoever applies the patch can fix the typo?
> the separate 'path' variable which is guaranteed terminated.
>
> Fixes a bug spotted by coverity that was introduced in
>
> commit ad9579aaa16d5b385922d49edac2c96c79bcfb62
> Author: Daniel P. Berrange <berrange@redhat.com>
> Date: Thu May 25 16:53:00 2017 +0100
>
> sockets: improve error reporting if UNIX socket path is too long
>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v2] sockets: avoid formatting buffer that may not be NUL terminated
2017-06-26 10:37 [Qemu-devel] [PATCH v2] sockets: avoid formatting buffer that may not be NUL terminated Daniel P. Berrange
2017-06-26 10:42 ` Peter Maydell
@ 2017-06-27 13:05 ` Michael Tokarev
1 sibling, 0 replies; 3+ messages in thread
From: Michael Tokarev @ 2017-06-27 13:05 UTC (permalink / raw)
To: Daniel P. Berrange, qemu-devel
Cc: Peter Maydell, Thomas Huth, qemu-trivial, Gerd Hoffmann,
Paolo Bonzini
Applied to -trivial (with commit typo fix), thanks!
/mjt
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-06-27 13:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-26 10:37 [Qemu-devel] [PATCH v2] sockets: avoid formatting buffer that may not be NUL terminated Daniel P. Berrange
2017-06-26 10:42 ` Peter Maydell
2017-06-27 13:05 ` Michael Tokarev
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).