]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix misparsing of portless IPv6 addresses
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 6 Oct 2010 09:48:53 +0000 (09:48 +0000)
committerRudolf Polzer <divVerent@xonotic.org>
Wed, 6 Oct 2010 09:54:36 +0000 (11:54 +0200)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10514 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=560eb405cfebc3c582f09d1358c170aa4e885e1a

lhnet.c

diff --git a/lhnet.c b/lhnet.c
index bba8a68523e221493bd088cf19dd88c133e6e2fd..918ae06a7c17076ee34bb3433a62573ccc54c688 100644 (file)
--- a/lhnet.c
+++ b/lhnet.c
@@ -386,8 +386,12 @@ int LHNETADDRESS_FromString(lhnetaddress_t *vaddress, const char *string, int de
        address->addresstype = LHNETADDRESSTYPE_NONE;
        port = 0;
        colon = strrchr(string, ':');
-       if (colon)
+       if (colon && (colon == strchr(string, ':') || (string[0] == '[' && colon - string > 0 && colon[-1] == ']'))I)
+       //           EITHER: colon is the ONLY colon  OR: colon comes after [...] delimited IPv6 address
+       //           fixes misparsing of IPv6 addresses without port
+       {
                port = atoi(colon + 1);
+       }
        else
                colon = string + strlen(string);
        if (port == 0)