Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update miniupnpc #2378

Merged
merged 1 commit into from
Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions external/miniupnpc/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ build/
*.a
*.so
*.dll
*.dll.def
*.exe
*.lib
*.dylib
Makefile.bak
miniupnpcstrings.h
Expand All @@ -30,3 +33,4 @@ testigddescparse
validateigddescparse
dist/
miniupnpc.egg-info/
init
12 changes: 11 additions & 1 deletion external/miniupnpc/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
$Id: Changelog.txt,v 1.223 2016/04/19 21:06:20 nanard Exp $
$Id: Changelog.txt,v 1.226 2016/12/16 08:57:19 nanard Exp $
miniUPnP client Changelog.

2017/05/05:
Fix CVE-2017-8798 Thanks to tin/Team OSTStrom

2016/11/11:
check strlen before memcmp in XML parsing portlistingparse.c
fix build under SOLARIS and CYGWIN

2016/10/11:
Add python 3 compatibility to IGD test

VERSION 2.0 : released 2016/04/19

2016/01/24:
Expand Down
2 changes: 1 addition & 1 deletion external/miniupnpc/LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MiniUPnPc
Copyright (c) 2005-2015, Thomas BERNARD
Copyright (c) 2005-2016, Thomas BERNARD
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 2 additions & 0 deletions external/miniupnpc/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
include README
include VERSION
include LICENSE
include miniupnpcmodule.c
include setup.py
include *.h
Expand Down
20 changes: 12 additions & 8 deletions external/miniupnpc/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# $Id: Makefile,v 1.133 2016/01/24 17:24:35 nanard Exp $
# $Id: Makefile,v 1.134 2016/10/07 09:04:36 nanard Exp $
# MiniUPnP Project
# http://miniupnp.free.fr/
# http://miniupnp.tuxfamily.org/
# https://github.com/miniupnp/miniupnp
# (c) 2005-2015 Thomas Bernard
# (c) 2005-2017 Thomas Bernard
# to install use :
# $ make DESTDIR=/tmp/dummylocation install
# or
Expand Down Expand Up @@ -48,7 +48,7 @@ CFLAGS += -D_XOPEN_SOURCE=600
endif
endif
#CFLAGS += -ansi
# -DNO_GETADDRINFO
#CFLAGS += -DNO_GETADDRINFO
INSTALL = install
SH = /bin/sh
JAVA = java
Expand All @@ -65,7 +65,9 @@ JNAERATORARGS = -mode StandaloneJar -runtime JNAerator -library miniupnpc
JNAERATORBASEURL = https://repo1.maven.org/maven2/com/nativelibs4java/jnaerator/0.12

ifeq (SunOS, $(OS))
LDFLAGS=-lsocket -lnsl -lresolv
LDLIBS=-lsocket -lnsl -lresolv
CFLAGS += -D__EXTENSIONS__
CFLAGS += -std=c99
endif

# APIVERSION is used to build SONAME
Expand All @@ -85,7 +87,9 @@ LIBOBJS = miniwget.o minixml.o igd_desc_parse.o minisoap.o \
connecthostport.o portlistingparse.o receivedata.o upnpdev.o

ifneq ($(OS), AmigaOS)
ifeq (,$(findstring CYGWIN,$(OS)))
CFLAGS := -fPIC $(CFLAGS)
endif
LIBOBJS := $(LIBOBJS) minissdpc.o
endif

Expand Down Expand Up @@ -169,18 +173,18 @@ check: validateminixml validateminiwget validateupnpreplyparse \
everything: all $(EXECUTABLES_ADDTESTS)

pythonmodule: $(LIBRARY) miniupnpcmodule.c setup.py
python setup.py build
MAKE=$(MAKE) python setup.py build
touch $@

installpythonmodule: pythonmodule
python setup.py install
MAKE=$(MAKE) python setup.py install

pythonmodule3: $(LIBRARY) miniupnpcmodule.c setup.py
python3 setup.py build
MAKE=$(MAKE) python3 setup.py build
touch $@

installpythonmodule3: pythonmodule3
python3 setup.py install
MAKE=$(MAKE) python3 setup.py install

validateminixml: minixmlvalid
@echo "minixml validation test"
Expand Down
7 changes: 3 additions & 4 deletions external/miniupnpc/README
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
Project: miniupnp
Project web page: http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
Project web page: http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
github: https://github.com/miniupnp/miniupnp
freecode: http://freecode.com/projects/miniupnp
Author: Thomas Bernard
Copyright (c) 2005-2016 Thomas Bernard
Copyright (c) 2005-2017 Thomas Bernard
This software is subject to the conditions detailed in the
LICENSE file provided within this distribution.

Expand Down Expand Up @@ -58,7 +57,7 @@ If you are using libminiupnpc in your application, please
send me an email !

For any question, you can use the web forum :
http://miniupnp.tuxfamily.org/forum/
https://miniupnp.tuxfamily.org/forum/

Bugs should be reported on github :
https://github.com/miniupnp/miniupnp/issues
10 changes: 4 additions & 6 deletions external/miniupnpc/connecthostport.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* $Id: connecthostport.c,v 1.15 2015/10/09 16:26:19 nanard Exp $ */
/* Project : miniupnp
* Author : Thomas Bernard
* Copyright (c) 2010-2015 Thomas Bernard
* Copyright (c) 2010-2017 Thomas Bernard
* This software is subject to the conditions detailed in the
* LICENCE file provided in this distribution. */

Expand Down Expand Up @@ -36,15 +36,13 @@
/* defining MINIUPNPC_IGNORE_EINTR enable the ignore of interruptions
* during the connect() call */
#define MINIUPNPC_IGNORE_EINTR
#ifndef USE_GETHOSTBYNAME
#include <sys/socket.h>
#include <sys/select.h>
#endif /* #ifndef USE_GETHOSTBYNAME */
#endif /* #else _WIN32 */

/* definition of PRINT_SOCKET_ERROR */
#ifdef _WIN32
#define PRINT_SOCKET_ERROR(x) printf("Socket error: %s, %d\n", x, WSAGetLastError());
#define PRINT_SOCKET_ERROR(x) fprintf(stderr, "Socket error: %s, %d\n", x, WSAGetLastError());
#else
#define PRINT_SOCKET_ERROR(x) perror(x)
#endif
Expand Down Expand Up @@ -100,13 +98,13 @@ int connecthostport(const char * host, unsigned short port,
timeout.tv_usec = 0;
if(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(struct timeval)) < 0)
{
PRINT_SOCKET_ERROR("setsockopt");
PRINT_SOCKET_ERROR("setsockopt SO_RCVTIMEO");
}
timeout.tv_sec = 3;
timeout.tv_usec = 0;
if(setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(struct timeval)) < 0)
{
PRINT_SOCKET_ERROR("setsockopt");
PRINT_SOCKET_ERROR("setsockopt SO_SNDTIMEO");
}
#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */
dest.sin_family = AF_INET;
Expand Down
6 changes: 3 additions & 3 deletions external/miniupnpc/minihttptestserver.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* $Id: minihttptestserver.c,v 1.19 2015/11/17 09:07:17 nanard Exp $ */
/* Project : miniUPnP
* Author : Thomas Bernard
* Copyright (c) 2011-2015 Thomas Bernard
* Copyright (c) 2011-2016 Thomas Bernard
* This software is subject to the conditions detailed in the
* LICENCE file provided in this distribution.
* */
Expand Down Expand Up @@ -611,7 +611,7 @@ int main(int argc, char * * argv) {
if(pid < 0) {
perror("wait");
} else {
printf("child(%d) terminated with status %d\n", pid, status);
printf("child(%d) terminated with status %d\n", (int)pid, status);
}
--child_to_wait_for;
}
Expand Down Expand Up @@ -648,7 +648,7 @@ int main(int argc, char * * argv) {
if(pid < 0) {
perror("wait");
} else {
printf("child(%d) terminated with status %d\n", pid, status);
printf("child(%d) terminated with status %d\n", (int)pid, status);
}
--child_to_wait_for;
}
Expand Down
2 changes: 1 addition & 1 deletion external/miniupnpc/minisoap.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <stdlib.h>

#ifdef _WIN32
#define PRINT_SOCKET_ERROR(x) printf("Socket error: %s, %d\n", x, WSAGetLastError());
#define PRINT_SOCKET_ERROR(x) fprintf(stderr, "Socket error: %s, %d\n", x, WSAGetLastError());
#else
#define PRINT_SOCKET_ERROR(x) perror(x)
#endif
Expand Down
57 changes: 37 additions & 20 deletions external/miniupnpc/minissdpc.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* $Id: minissdpc.c,v 1.28 2015/09/18 13:05:39 nanard Exp $ */
/* $Id: minissdpc.c,v 1.32 2016/10/07 09:04:36 nanard Exp $ */
/* vim: tabstop=4 shiftwidth=4 noexpandtab
* Project : miniupnp
* Web : http://miniupnp.free.fr/
* Author : Thomas BERNARD
* copyright (c) 2005-2015 Thomas Bernard
* copyright (c) 2005-2017 Thomas Bernard
* This software is subjet to the conditions detailed in the
* provided LICENCE file. */
/*#include <syslog.h>*/
Expand Down Expand Up @@ -62,7 +62,7 @@ struct sockaddr_un {
#endif

#ifdef _WIN32
#define PRINT_SOCKET_ERROR(x) printf("Socket error: %s, %d\n", x, WSAGetLastError());
#define PRINT_SOCKET_ERROR(x) fprintf(stderr, "Socket error: %s, %d\n", x, WSAGetLastError());
#else
#define PRINT_SOCKET_ERROR(x) perror(x)
#endif
Expand All @@ -73,6 +73,9 @@ struct sockaddr_un {

#if !defined(HAS_IP_MREQN) && !defined(_WIN32)
#include <sys/ioctl.h>
#if defined(__sun)
#include <sys/sockio.h>
#endif
#endif

#if defined(HAS_IP_MREQN) && defined(NEED_STRUCT_IP_MREQN)
Expand Down Expand Up @@ -169,7 +172,7 @@ connectToMiniSSDPD(const char * socketpath)
{
int s;
struct sockaddr_un addr;
#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT
#if defined(MINIUPNPC_SET_SOCKET_TIMEOUT) && !defined(__sun)
struct timeval timeout;
#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */

Expand All @@ -180,23 +183,25 @@ connectToMiniSSDPD(const char * socketpath)
perror("socket(unix)");
return MINISSDPC_SOCKET_ERROR;
}
#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT
#if defined(MINIUPNPC_SET_SOCKET_TIMEOUT) && !defined(__sun)
/* setting a 3 seconds timeout */
/* not supported for AF_UNIX sockets under Solaris */
timeout.tv_sec = 3;
timeout.tv_usec = 0;
if(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(struct timeval)) < 0)
{
perror("setsockopt");
perror("setsockopt SO_RCVTIMEO unix");
}
timeout.tv_sec = 3;
timeout.tv_usec = 0;
if(setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(struct timeval)) < 0)
{
perror("setsockopt");
perror("setsockopt SO_SNDTIMEO unix");
}
#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */
if(!socketpath)
socketpath = "/var/run/minissdpd.sock";
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, socketpath, sizeof(addr.sun_path));
/* TODO : check if we need to handle the EINTR */
Expand Down Expand Up @@ -498,6 +503,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
unsigned long _ttl = (unsigned long)ttl;
#endif
int linklocal = 1;
int sentok;

if(error)
*error = MINISSDPC_UNKNOWN_ERROR;
Expand Down Expand Up @@ -608,14 +614,22 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
return NULL;
}

if(ipv6) {
int mcastHops = ttl;
if(setsockopt(sudp, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &mcastHops, sizeof(mcastHops)) < 0)
{
PRINT_SOCKET_ERROR("setsockopt(IPV6_MULTICAST_HOPS,...)");
}
} else {
#ifdef _WIN32
if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_TTL, (const char *)&_ttl, sizeof(_ttl)) < 0)
if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_TTL, (const char *)&_ttl, sizeof(_ttl)) < 0)
#else /* _WIN32 */
if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0)
if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0)
#endif /* _WIN32 */
{
/* not a fatal error */
PRINT_SOCKET_ERROR("setsockopt(IP_MULTICAST_TTL,...)");
{
/* not a fatal error */
PRINT_SOCKET_ERROR("setsockopt(IP_MULTICAST_TTL,...)");
}
}

if(multicastif)
Expand All @@ -628,7 +642,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
unsigned int ifindex = if_nametoindex(multicastif); /* eth0, etc. */
if(setsockopt(sudp, IPPROTO_IPV6, IPV6_MULTICAST_IF, &ifindex, sizeof(ifindex)) < 0)
{
PRINT_SOCKET_ERROR("setsockopt");
PRINT_SOCKET_ERROR("setsockopt IPV6_MULTICAST_IF");
}
#else
#ifdef DEBUG
Expand All @@ -643,7 +657,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
((struct sockaddr_in *)&sockudp_r)->sin_addr.s_addr = mc_if.s_addr;
if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF, (const char *)&mc_if, sizeof(mc_if)) < 0)
{
PRINT_SOCKET_ERROR("setsockopt");
PRINT_SOCKET_ERROR("setsockopt IP_MULTICAST_IF");
}
} else {
#ifdef HAS_IP_MREQN
Expand All @@ -653,7 +667,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
reqn.imr_ifindex = if_nametoindex(multicastif);
if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF, (const char *)&reqn, sizeof(reqn)) < 0)
{
PRINT_SOCKET_ERROR("setsockopt");
PRINT_SOCKET_ERROR("setsockopt IP_MULTICAST_IF");
}
#elif !defined(_WIN32)
struct ifreq ifr;
Expand All @@ -667,7 +681,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
mc_if.s_addr = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;
if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF, (const char *)&mc_if, sizeof(mc_if)) < 0)
{
PRINT_SOCKET_ERROR("setsockopt");
PRINT_SOCKET_ERROR("setsockopt IP_MULTICAST_IF");
}
#else /* _WIN32 */
#ifdef DEBUG
Expand Down Expand Up @@ -700,6 +714,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
}
/* receiving SSDP response packet */
for(deviceIndex = 0; deviceTypes[deviceIndex]; deviceIndex++) {
sentok = 0;
/* sending the SSDP M-SEARCH packet */
n = snprintf(bufr, sizeof(bufr),
MSearchMsgFmt,
Expand Down Expand Up @@ -743,7 +758,8 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
if(error)
*error = MINISSDPC_SOCKET_ERROR;
PRINT_SOCKET_ERROR("sendto");
break;
} else {
sentok = 1;
}
#else /* #ifdef NO_GETADDRINFO */
memset(&hints, 0, sizeof(hints));
Expand Down Expand Up @@ -775,19 +791,20 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
#endif
PRINT_SOCKET_ERROR("sendto");
continue;
} else {
sentok = 1;
}
}
freeaddrinfo(servinfo);
if(n < 0) {
if(!sentok) {
if(error)
*error = MINISSDPC_SOCKET_ERROR;
break;
}
#endif /* #ifdef NO_GETADDRINFO */
/* Waiting for SSDP REPLY packet to M-SEARCH
* if searchalltypes is set, enter the loop only
* when the last deviceType is reached */
if(!searchalltypes || !deviceTypes[deviceIndex + 1]) do {
if((sentok && !searchalltypes) || !deviceTypes[deviceIndex + 1]) do {
n = receivedata(sudp, bufr, sizeof(bufr), delay, &scope_id);
if (n < 0) {
/* error */
Expand Down
Loading