- Timestamp:
- 2018-03-10T11:30:39Z (7 years ago)
- 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. - Location:
- lib
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/Makefile
r3f44e43 r7a9d968 13 13 14 14 # [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.o15 objects = 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 16 16 17 17 LFLAGS += -r … … 36 36 lib.o: $(objects) $(subdirs) 37 37 @echo '*' Linking lib.o 38 @$(LD) $(LFLAGS) $(objects) -o lib.o38 $(VERBOSE) $(LD) $(LFLAGS) $(objects) -o lib.o 39 39 40 40 $(objects): ../Makefile.settings Makefile … … 42 42 $(objects): %.o: $(_SRCDIR_)%.c 43 43 @echo '*' Compiling $< 44 @$(CC) -c $(CFLAGS) $(CFLAGS_BITLBEE) $< -o $@44 $(VERBOSE) $(CC) -c $(CFLAGS) $(CFLAGS_BITLBEE) $< -o $@ 45 45 46 46 -include .depend/*.d -
lib/ftutil.c
r3f44e43 r7a9d968 42 42 struct addrinfo hints, *rp; 43 43 socklen_t ssize = sizeof(struct sockaddr_storage); 44 struct sockaddr_storage saddrs , *saddr = &saddrs;44 struct sockaddr_storage saddrs = {0}, *saddr = &saddrs; 45 45 static char errmsg[1024]; 46 46 char *ftlisten = global.conf->ft_listen; … … 63 63 if (for_bitlbee_client) { 64 64 *scolon = '\0'; 65 strncpy(host, ftlisten, HOST_NAME_MAX);65 strncpy(host, ftlisten, NI_MAXHOST); 66 66 *scolon = ';'; 67 67 } else { 68 strncpy(host, scolon + 1, HOST_NAME_MAX);68 strncpy(host, scolon + 1, NI_MAXHOST); 69 69 } 70 70 } else { 71 strncpy(host, ftlisten, HOST_NAME_MAX);71 strncpy(host, ftlisten, NI_MAXHOST); 72 72 } 73 73 … … 78 78 } else if (copy_fd >= 0 && getsockname(copy_fd, (struct sockaddr*) &saddrs, &ssize) == 0 && 79 79 (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, 81 81 NULL, 0, NI_NUMERICHOST) == 0) { 82 82 /* We just took our local address on copy_fd, which is likely to be a … … 84 84 most sensible we can get easily. */ 85 85 } else { 86 ASSERTSOCKOP(gethostname(host, HOST_NAME_MAX + 1), "gethostname()");86 ASSERTSOCKOP(gethostname(host, NI_MAXHOST), "gethostname()"); 87 87 } 88 88 … … 109 109 ( void * ) &(( struct sockaddr_in * ) saddr)->sin_addr.s_addr : 110 110 ( void * ) &(( struct sockaddr_in6 * ) saddr)->sin6_addr.s6_addr, 111 host, HOST_NAME_MAX)) {111 host, NI_MAXHOST)) { 112 112 strcpy(errmsg, "inet_ntop failed on listening socket"); 113 113 return -1; … … 128 128 129 129 /* I hate static-length strings.. */ 130 host[ HOST_NAME_MAX- 1] = '\0';130 host[NI_MAXHOST - 1] = '\0'; 131 131 port[5] = '\0'; 132 132 -
lib/ftutil.h
r3f44e43 r7a9d968 26 26 #endif 27 27 28 /* Some ifdefs for ulibc and apparently also BSD (Thanks to Whoopie) */29 #ifndef HOST_NAME_MAX30 #include <sys/param.h>31 #ifdef MAXHOSTNAMELEN32 #define HOST_NAME_MAX MAXHOSTNAMELEN33 #else34 #define HOST_NAME_MAX 25535 #endif36 #endif37 38 28 /* 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]. */ 40 30 int ft_listen(struct sockaddr_storage *saddr_ptr, char *host, char *port, int copy_fd, int for_bitlbee_client, 41 31 char **errptr); -
lib/misc.c
r3f44e43 r7a9d968 1 /********************************************************************\1 /********************************************************************\ 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * … … 335 335 } 336 336 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 382 337 /* Convert from one charset to another. 383 338 -
lib/misc.h
r3f44e43 r7a9d968 29 29 #include <gmodule.h> 30 30 #include <time.h> 31 #include <sys/socket.h> 31 32 32 33 struct ns_srv_reply { … … 130 131 G_MODULE_EXPORT void http_encode(char *s); 131 132 132 G_MODULE_EXPORT char *ipv6_wrap(char *src);133 G_MODULE_EXPORT char *ipv6_unwrap(char *src);134 135 133 G_MODULE_EXPORT signed int do_iconv(char *from_cs, char *to_cs, char *src, char *dst, size_t size, size_t maxbuf); 136 134
Note: See TracChangeset
for help on using the changeset viewer.