]> Git Repo - qemu.git/commit
sockets: improve error reporting if UNIX socket path is too long
authorDaniel P. Berrange <[email protected]>
Thu, 25 May 2017 15:53:00 +0000 (16:53 +0100)
committerPaolo Bonzini <[email protected]>
Wed, 7 Jun 2017 16:22:02 +0000 (18:22 +0200)
commitad9579aaa16d5b385922d49edac2c96c79bcfb62
treee5c01384ad220119c515d074354991ea96304722
parent5b003a40bb1ab14d0398e91f03393d3c6b9577cd
sockets: improve error reporting if UNIX socket path is too long

The 'struct sockaddr_un' only allows 108 bytes for the socket
path.

If the user supplies a path, QEMU uses snprintf() to silently
truncate it when too long. This is undesirable because the user
will then be unable to connect to the path they asked for.

If the user doesn't supply a path, QEMU builds one based on
TMPDIR, but if that leads to an overlong path, it mistakenly
uses error_setg_errno() with a stale errno value, because
snprintf() does not set errno on truncation.

In solving this the code needed some refactoring to ensure we
don't pass 'un.sun_path' directly to any APIs which expect
NUL-terminated strings, because the path is not required to
be terminated.

Signed-off-by: Daniel P. Berrange <[email protected]>
Message-Id: <20170525155300[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
util/qemu-sockets.c
This page took 0.025453 seconds and 4 git commands to generate.