Re: PATCH: 1/10: SASL authentication support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Dan

I haven't used getnameinfo much, so looked it up and found this:

       In order to assist the programmer in choosing reasonable sizes for  the
       supplied buffers, <netdb.h> defines the constants

            # define NI_MAXHOST      1025
            # define NI_MAXSERV      32

"Daniel P. Berrange" <berrange@xxxxxxxxxx> wrote:
...
> diff -r 1c3780349e89 qemud/remote.c
> --- a/qemud/remote.c	Wed Nov 28 12:02:28 2007 -0500
> +++ b/qemud/remote.c	Thu Nov 29 09:24:10 2007 -0500
...
> +static char *addrToString(struct qemud_client *client,
> +                          remote_message_header *req,
> +                          struct sockaddr_storage *sa, socklen_t salen) {
> +    char host[1024], port[20];
> +    char *addr;
> +    int err;
> +
> +    if ((err = getnameinfo((struct sockaddr *)sa, salen,
> +                           host, sizeof(host),
> +                           port, sizeof(port),
> +                           NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {

Since it's always good to avoid such literals, how about declaring
those locals like this:

    char host[NI_MAXHOST];
    port[NI_MAXSERV];

I see that qemud/remote.c already includes <netdb.h>,
but if you're extra cautious, maybe you'd want this:
(though NI_MAXHOST is already used in qemud.c, so maybe not):

#ifndef NI_MAXHOST
# define NI_MAXHOST 1025
#endif
#ifndef NI_MAXSERV
# define NI_MAXSERV 32
#endif

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]