Ignore:
Timestamp:
Jul 26, 2011, 1:36:30 AM (10 years ago)
Author:
livings124
Message:

#4387 Update miniupnpc to 1.6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/third-party/miniupnp/connecthostport.c

    r11577 r12593  
    1 /* $Id: connecthostport.c,v 1.3 2010/12/21 16:13:14 nanard Exp $ */
     1/* $Id: connecthostport.c,v 1.5 2011/04/09 08:49:50 nanard Exp $ */
    22/* Project : miniupnp
    33 * Author : Thomas Bernard
    4  * Copyright (c) 2010 Thomas Bernard
     4 * Copyright (c) 2010-2011 Thomas Bernard
    55 * This software is subject to the conditions detailed in the
    66 * LICENCE file provided in this distribution. */
     
    1818#include <ws2tcpip.h>
    1919#include <io.h>
     20#define MAXHOSTNAMELEN 64
    2021#define snprintf _snprintf
    2122#define herror
     
    2324#else /* #ifdef WIN32 */
    2425#include <unistd.h>
     26#include <sys/param.h>
    2527#include <errno.h>
    2628#define closesocket close
     
    5860        struct hostent *hp;
    5961#else /* #ifdef USE_GETHOSTBYNAME */
     62        char tmp_host[MAXHOSTNAMELEN+1];
    6063        char port_str[8];
    6164        struct addrinfo *ai, *p;
     
    140143        /* hints.ai_protocol = IPPROTO_TCP; */
    141144        snprintf(port_str, sizeof(port_str), "%hu", port);
    142         n = getaddrinfo(host, port_str, &hints, &ai);
     145        if(host[0] == '[')
     146        {
     147                /* literal ip v6 address */
     148                int i;
     149                for(i = 0; host[i+1] && (host[i+1] != ']') && i < MAXHOSTNAMELEN; i++)
     150                {
     151                        tmp_host[i] = host[i+1];
     152                }
     153                tmp_host[i] = '\0';
     154        }
     155        else
     156        {
     157                strncpy(tmp_host, host, MAXHOSTNAMELEN);
     158        }
     159        tmp_host[MAXHOSTNAMELEN] = '\0';
     160        n = getaddrinfo(tmp_host, port_str, &hints, &ai);
    143161        if(n != 0)
    144162        {
Note: See TracChangeset for help on using the changeset viewer.