[libvirt] [PATCHv2] virnetserver: handle sigaction correctly
Eric Blake
eblake at redhat.com
Fri Apr 20 03:50:35 UTC 2012
On 04/19/2012 09:45 PM, Eric Blake wrote:
> POSIX says that sa_sigaction is only safe to use if sa_flags
> includes SA_SIGINFO; conversely, sa_handler is only safe to
> use when flags excludes that bit. Gnulib doesn't guarantee
> an implementation of SA_SIGINFO, but does guarantee that
> if SA_SIGINFO is undefined, we can safely define it to 0 as
> long as we don't dereference the 2nd or 3rd argument of
> any handler otherwise registered via sa_sigaction.
>
> Based on a report by Wen Congyang.
>
> * src/rpc/virnetserver.c (SA_SIGINFO): Stub for mingw.
> (virNetServerSignalHandler): Avoid bogus dereference.
> (virNetServerFatalSignal, virNetServerNew): Set flags properly.
> ---
> +static void
> +virNetServerSignalHandler(int sig, siginfo_t * siginfo ATTRIBUTE_UNUSED,
> + void* context ATTRIBUTE_UNUSED)
> {
> int origerrno;
> int r;
> + siginfo_t tmp;
> +
> + if (SA_SIGINFO)
> + tmp = *siginfo;
> + else
> + memset(&tmp, 0, sizeof(tmp));
>
> /* set the sig num in the struct */
> - siginfo->si_signo = sig;
> + tmp->si_signo = sig;
I typo'd that (serves me right for sending before one last compile
test); it should be tmp.si_signo.
--
Eric Blake eblake at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120419/2aab745f/attachment-0001.sig>
More information about the libvir-list
mailing list