Changeset 7a9d968 for lib


Ignore:
Timestamp:
2018-03-10T11:30:39Z (7 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Children:
5447c59
Parents:
3f44e43 (diff), 4a9c6b0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into HEAD

Location:
lib
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • lib/Makefile

    r3f44e43 r7a9d968  
    1313
    1414# [SH] Program variables
    15 objects = arc.o base64.o $(EVENT_HANDLER) ftutil.o http_client.o ini.o md5.o misc.o oauth.o oauth2.o parson.o proxy.o sha1.o $(SSL_CLIENT) url.o xmltree.o ns_parse.o
     15objects = arc.o base64.o canohost.o $(EVENT_HANDLER) ftutil.o http_client.o ini.o md5.o misc.o oauth.o oauth2.o parson.o proxy.o sha1.o $(SSL_CLIENT) url.o xmltree.o ns_parse.o
    1616
    1717LFLAGS += -r
     
    3636lib.o: $(objects) $(subdirs)
    3737        @echo '*' Linking lib.o
    38         @$(LD) $(LFLAGS) $(objects) -o lib.o
     38        $(VERBOSE) $(LD) $(LFLAGS) $(objects) -o lib.o
    3939
    4040$(objects): ../Makefile.settings Makefile
     
    4242$(objects): %.o: $(_SRCDIR_)%.c
    4343        @echo '*' Compiling $<
    44         @$(CC) -c $(CFLAGS) $(CFLAGS_BITLBEE) $< -o $@
     44        $(VERBOSE) $(CC) -c $(CFLAGS) $(CFLAGS_BITLBEE) $< -o $@
    4545
    4646-include .depend/*.d
  • lib/ftutil.c

    r3f44e43 r7a9d968  
    4242        struct addrinfo hints, *rp;
    4343        socklen_t ssize = sizeof(struct sockaddr_storage);
    44         struct sockaddr_storage saddrs, *saddr = &saddrs;
     44        struct sockaddr_storage saddrs = {0}, *saddr = &saddrs;
    4545        static char errmsg[1024];
    4646        char *ftlisten = global.conf->ft_listen;
     
    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

    r3f44e43 r7a9d968  
    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);
  • lib/misc.c

    r3f44e43 r7a9d968  
    1 /********************************************************************\
     1  /********************************************************************\
    22  * BitlBee -- An IRC to other IM-networks gateway                     *
    33  *                                                                    *
     
    335335}
    336336
    337 /* Wrap an IPv4 address into IPv6 space. Not thread-safe... */
    338 char *ipv6_wrap(char *src)
    339 {
    340         static char dst[64];
    341         int i;
    342 
    343         for (i = 0; src[i]; i++) {
    344                 if ((src[i] < '0' || src[i] > '9') && src[i] != '.') {
    345                         break;
    346                 }
    347         }
    348 
    349         /* Hmm, it's not even an IP... */
    350         if (src[i]) {
    351                 return src;
    352         }
    353 
    354         g_snprintf(dst, sizeof(dst), "::ffff:%s", src);
    355 
    356         return dst;
    357 }
    358 
    359 /* Unwrap an IPv4 address into IPv6 space. Thread-safe, because it's very simple. :-) */
    360 char *ipv6_unwrap(char *src)
    361 {
    362         int i;
    363 
    364         if (g_strncasecmp(src, "::ffff:", 7) != 0) {
    365                 return src;
    366         }
    367 
    368         for (i = 7; src[i]; i++) {
    369                 if ((src[i] < '0' || src[i] > '9') && src[i] != '.') {
    370                         break;
    371                 }
    372         }
    373 
    374         /* Hmm, it's not even an IP... */
    375         if (src[i]) {
    376                 return src;
    377         }
    378 
    379         return (src + 7);
    380 }
    381 
    382337/* Convert from one charset to another.
    383338
  • lib/misc.h

    r3f44e43 r7a9d968  
    2929#include <gmodule.h>
    3030#include <time.h>
     31#include <sys/socket.h>
    3132
    3233struct ns_srv_reply {
     
    130131G_MODULE_EXPORT void http_encode(char *s);
    131132
    132 G_MODULE_EXPORT char *ipv6_wrap(char *src);
    133 G_MODULE_EXPORT char *ipv6_unwrap(char *src);
    134 
    135133G_MODULE_EXPORT signed int do_iconv(char *from_cs, char *to_cs, char *src, char *dst, size_t size, size_t maxbuf);
    136134
Note: See TracChangeset for help on using the changeset viewer.