diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..3708a87c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: c + +compiler: + - gcc + - clang + +os: + - linux + - osx + +script: + - make diff --git a/build.xml b/build.xml index 6e796a1f..84433e78 100644 --- a/build.xml +++ b/build.xml @@ -31,6 +31,7 @@ + @@ -127,7 +128,7 @@ - + diff --git a/src/MQTTPersistenceDefault.c b/src/MQTTPersistenceDefault.c index 357a4302..0f4f163c 100755 --- a/src/MQTTPersistenceDefault.c +++ b/src/MQTTPersistenceDefault.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2014 IBM Corp. + * Copyright (c) 2009, 2016 IBM Corp. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -13,6 +13,7 @@ * Contributors: * Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - async client updates + * Ian Craggs - fix for bug 484496 *******************************************************************************/ /** @@ -73,8 +74,8 @@ int pstopen(void **handle, const char* clientID, const char* serverURI, void* co /* Note that serverURI=address:port, but ":" not allowed in Windows directories */ perserverURI = malloc(strlen(serverURI) + 1); strcpy(perserverURI, serverURI); - ptraux = strstr(perserverURI, ":"); - *ptraux = '-' ; + while ((ptraux = strstr(perserverURI, ":")) != NULL) + *ptraux = '-' ; /* consider '/' + '-' + '\0' */ clientDir = malloc(strlen(dataDir) + strlen(clientID) + strlen(perserverURI) + 3); diff --git a/src/Socket.c b/src/Socket.c index b7321e69..536fb054 100755 --- a/src/Socket.c +++ b/src/Socket.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2014 IBM Corp. + * Copyright (c) 2009, 2016 IBM Corp. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -13,6 +13,7 @@ * Contributors: * Ian Craggs - initial implementation and documentation * Ian Craggs - async client updates + * Ian Craggs - fix for bug 484496 *******************************************************************************/ /** @@ -601,6 +602,7 @@ int Socket_new(char* addr, int port, int* sock) FUNC_ENTRY; *sock = -1; + memset(&address6, '\0', sizeof(address6)); if (addr[0] == '[') ++addr; @@ -609,13 +611,10 @@ int Socket_new(char* addr, int port, int* sock) { struct addrinfo* res = result; - /* prefer ip4 addresses */ while (res) - { - if (res->ai_family == AF_INET) - { + { /* prefer ip4 addresses */ + if (res->ai_family == AF_INET || res->ai_next == NULL) break; - } res = res->ai_next; } @@ -627,7 +626,7 @@ int Socket_new(char* addr, int port, int* sock) { address6.sin6_port = htons(port); address6.sin6_family = family = AF_INET6; - address6.sin6_addr = ((struct sockaddr_in6*)(res->ai_addr))->sin6_addr; + memcpy(&address6.sin6_addr, &((struct sockaddr_in6*)(res->ai_addr))->sin6_addr, sizeof(address6.sin6_addr)); } else #endif