Changeset 2e8523b


Ignore:
Timestamp:
2016-12-31T20:40:09Z (4 years ago)
Author:
dx <dx@…>
Branches:
master
Children:
188b75e, 8768f67
Parents:
7801298
git-author:
Jelmer Vernooij <jelmer@…> (28-12-16 13:50:14)
git-committer:
dx <dx@…> (31-12-16 20:40:09)
Message:

Use NI_MAXHOST rather than HOST_NAME_MAX for host lengths.

This constant is always available and meant to be used with
getnameinfo().

This fixes the build on Debian GNU/kFreeBSD.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • dcc.c

    r7801298 r2e8523b  
    9292        struct sockaddr_storage saddr;
    9393        char *errmsg;
    94         char host[HOST_NAME_MAX];
     94        char host[NI_MAXHOST];
    9595        char port[6];
    9696
  • lib/ftutil.c

    r7801298 r2e8523b  
    6363                        if (for_bitlbee_client) {
    6464                                *scolon = '\0';
    65                                 strncpy(host, ftlisten, HOST_NAME_MAX);
     65                                strncpy(host, ftlisten, NI_MAXHOST);
    6666                                *scolon = ';';
    6767                        } else {
    68                                 strncpy(host, scolon + 1, HOST_NAME_MAX);
     68                                strncpy(host, scolon + 1, NI_MAXHOST);
    6969                        }
    7070                } else {
    71                         strncpy(host, ftlisten, HOST_NAME_MAX);
     71                        strncpy(host, ftlisten, NI_MAXHOST);
    7272                }
    7373
     
    7878        } else if (copy_fd >= 0 && getsockname(copy_fd, (struct sockaddr*) &saddrs, &ssize) == 0 &&
    7979                   (saddrs.ss_family == AF_INET || saddrs.ss_family == AF_INET6) &&
    80                    getnameinfo((struct sockaddr*) &saddrs, ssize, host, HOST_NAME_MAX,
     80                   getnameinfo((struct sockaddr*) &saddrs, ssize, host, NI_MAXHOST,
    8181                               NULL, 0, NI_NUMERICHOST) == 0) {
    8282                /* We just took our local address on copy_fd, which is likely to be a
     
    8484                   most sensible we can get easily. */
    8585        } else {
    86                 ASSERTSOCKOP(gethostname(host, HOST_NAME_MAX + 1), "gethostname()");
     86                ASSERTSOCKOP(gethostname(host, NI_MAXHOST), "gethostname()");
    8787        }
    8888
     
    109109                       ( void * ) &(( struct sockaddr_in * ) saddr)->sin_addr.s_addr :
    110110                       ( void * ) &(( struct sockaddr_in6 * ) saddr)->sin6_addr.s6_addr,
    111                        host, HOST_NAME_MAX)) {
     111                       host, NI_MAXHOST)) {
    112112                strcpy(errmsg, "inet_ntop failed on listening socket");
    113113                return -1;
     
    128128
    129129        /* I hate static-length strings.. */
    130         host[HOST_NAME_MAX - 1] = '\0';
     130        host[NI_MAXHOST - 1] = '\0';
    131131        port[5] = '\0';
    132132
  • lib/ftutil.h

    r7801298 r2e8523b  
    2626#endif
    2727
    28 /* Some ifdefs for ulibc and apparently also BSD (Thanks to Whoopie) */
    29 #ifndef HOST_NAME_MAX
    30 #include <sys/param.h>
    31 #ifdef MAXHOSTNAMELEN
    32 #define HOST_NAME_MAX MAXHOSTNAMELEN
    33 #else
    34 #define HOST_NAME_MAX 255
    35 #endif
    36 #endif
    37 
    3828/* This function should be used with care. host should be AT LEAST a
    39    char[HOST_NAME_MAX+1] and port AT LEAST a char[6]. */
     29   char[NI_MAXHOST+1] and port AT LEAST a char[6]. */
    4030int ft_listen(struct sockaddr_storage *saddr_ptr, char *host, char *port, int copy_fd, int for_bitlbee_client,
    4131              char **errptr);
  • protocols/jabber/s5bytestream.c

    r7801298 r2e8523b  
    888888        char *proxy, *next, *errmsg = NULL;
    889889        char port[6];
    890         char host[HOST_NAME_MAX + 1];
     890        char host[NI_MAXHOST + 1];
    891891        jabber_streamhost_t *sh, *sh2;
    892892        GSList *streamhosts = jd->streamhosts;
Note: See TracChangeset for help on using the changeset viewer.