miniupnpc 2.3.1__tar.gz → 2.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/Makefile +4 -3
  2. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/PKG-INFO +1 -1
  3. miniupnpc-2.3.3/VERSION +1 -0
  4. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/include/miniupnpc.h +7 -5
  5. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/include/miniupnpctypes.h +1 -6
  6. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/include/miniwget.h +0 -25
  7. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/include/upnpcommands.h +78 -1
  8. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/include/upnpreplyparse.h +4 -11
  9. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/miniupnpc.egg-info/PKG-INFO +1 -1
  10. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/addr_is_reserved.c +1 -0
  11. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/connecthostport.c +16 -10
  12. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/minisoap.c +3 -3
  13. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/minissdpc.c +11 -8
  14. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/miniupnpc.c +1 -0
  15. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/miniwget.c +3 -2
  16. miniupnpc-2.3.3/src/miniwget_private.h +54 -0
  17. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/portlistingparse.c +4 -4
  18. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/receivedata.c +3 -2
  19. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/upnpcommands.c +133 -73
  20. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/upnpreplyparse.c +18 -3
  21. miniupnpc-2.3.1/VERSION +0 -1
  22. miniupnpc-2.3.1/src/miniwget_private.h +0 -15
  23. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/DESCRIPTION +0 -0
  24. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/LICENSE +0 -0
  25. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/MANIFEST.in +0 -0
  26. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/README +0 -0
  27. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/external-ip.sh +0 -0
  28. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/include/igd_desc_parse.h +0 -0
  29. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/include/miniupnpc_declspec.h +0 -0
  30. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/include/portlistingparse.h +0 -0
  31. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/include/upnpdev.h +0 -0
  32. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/include/upnperrors.h +0 -0
  33. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/miniupnpc.egg-info/SOURCES.txt +0 -0
  34. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/miniupnpc.egg-info/dependency_links.txt +0 -0
  35. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/miniupnpc.egg-info/top_level.txt +0 -0
  36. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/miniupnpcstrings.h.in +0 -0
  37. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/setup.cfg +0 -0
  38. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/setup.py +0 -0
  39. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/setupmingw32.py +0 -0
  40. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/addr_is_reserved.h +0 -0
  41. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/codelength.h +0 -0
  42. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/connecthostport.h +0 -0
  43. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/igd_desc_parse.c +0 -0
  44. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/listdevices.c +0 -0
  45. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/minihttptestserver.c +0 -0
  46. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/minisoap.h +0 -0
  47. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/minissdpc.h +0 -0
  48. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/miniupnpc_socketdef.h +0 -0
  49. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/miniupnpcmodule.c +0 -0
  50. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/minixml.c +0 -0
  51. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/minixml.h +0 -0
  52. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/minixmlvalid.c +0 -0
  53. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/receivedata.h +0 -0
  54. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/testaddr_is_reserved.c +0 -0
  55. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/testigddescparse.c +0 -0
  56. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/testminiwget.c +0 -0
  57. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/testminixml.c +0 -0
  58. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/testportlistingparse.c +0 -0
  59. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/testupnpreplyparse.c +0 -0
  60. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/upnpc.c +0 -0
  61. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/upnpdev.c +0 -0
  62. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/upnperrors.c +0 -0
  63. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/src/win32_snprintf.h +0 -0
  64. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/testminiwget.sh +0 -0
  65. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/testupnpreplyparse.sh +0 -0
  66. {miniupnpc-2.3.1 → miniupnpc-2.3.3}/updateminiupnpcstrings.sh +0 -0
@@ -1,4 +1,4 @@
1
- # $Id: Makefile,v 1.150 2023/06/15 22:55:24 nanard Exp $
1
+ # $Id: Makefile,v 1.156 2025/03/18 23:40:14 nanard Exp $
2
2
  # MiniUPnP Project
3
3
  # http://miniupnp.free.fr/
4
4
  # https://miniupnp.tuxfamily.org/
@@ -84,9 +84,10 @@ ifneq (, $(findstring sun, $(OS))$(findstring solaris, $(OS)))
84
84
  endif
85
85
 
86
86
  # APIVERSION is used to build SONAME
87
- APIVERSION = 19
87
+ APIVERSION = 21
88
88
 
89
89
  SRCS = $(wildcard $(SRCDIR)/*.c)
90
+ PRIVATE_HEADERS = $(wildcard $(SRCDIR)/*.h)
90
91
 
91
92
  LIBOBJS = $(addprefix $(BUILD)/,miniwget.o minixml.o igd_desc_parse.o minisoap.o \
92
93
  miniupnpc.o upnpreplyparse.o upnpcommands.o upnperrors.o \
@@ -399,7 +400,7 @@ ideb:
399
400
 
400
401
  minihttptestserver: minihttptestserver.o
401
402
 
402
- doxygen/html/index.html: Doxyfile $(SRCS) $(HEADERS)
403
+ doxygen/html/index.html: Doxyfile $(SRCS) $(HEADERS) $(PRIVATE_HEADERS)
403
404
  doxygen
404
405
 
405
406
  print-%:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: miniupnpc
3
- Version: 2.3.1
3
+ Version: 2.3.3
4
4
  Summary: MiniUPnP IGD client
5
5
  Home-page: https://miniupnp.tuxfamily.org/
6
6
  Author: Thomas BERNARD
@@ -0,0 +1 @@
1
+ 2.3.3
@@ -1,4 +1,4 @@
1
- /* $Id: miniupnpc.h,v 1.72 2025/02/08 23:15:16 nanard Exp $ */
1
+ /* $Id: miniupnpc.h,v 1.80 2025/05/26 22:56:40 nanard Exp $ */
2
2
  /* vim: tabstop=4 shiftwidth=4 noexpandtab
3
3
  * Project: miniupnp
4
4
  * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
@@ -19,7 +19,7 @@
19
19
  * MiniUPnPc (MiniUPnP client) is a library implementing a UPnP
20
20
  * Internet Gateway Device (IGD) control point.
21
21
  *
22
- * It should be used by applications that needs to listen to incoming
22
+ * It should be used by applications that need to listen to incoming
23
23
  * traffic from the internet which are running on a LAN where a
24
24
  * UPnP IGD is running on the router (or gateway).
25
25
  *
@@ -42,9 +42,9 @@
42
42
  #define UPNPDISCOVER_MEMORY_ERROR (-102)
43
43
 
44
44
  /*! \brief software version */
45
- #define MINIUPNPC_VERSION "2.3.1"
45
+ #define MINIUPNPC_VERSION "2.3.3"
46
46
  /*! \brief C API version */
47
- #define MINIUPNPC_API_VERSION 19
47
+ #define MINIUPNPC_API_VERSION 21
48
48
 
49
49
  /*! \brief any (ie system chosen) port */
50
50
  #define UPNP_LOCAL_PORT_ANY 0
@@ -68,6 +68,8 @@ struct UPNParg {
68
68
  /*!
69
69
  * \brief execute a UPnP method (SOAP action)
70
70
  *
71
+ * \todo error reporting should be improved
72
+ *
71
73
  * \param[in] url Control URL for the service
72
74
  * \param[in] service service to use
73
75
  * \param[in] action action to call
@@ -279,7 +281,7 @@ GetUPNPUrls(struct UPNPUrls * urls, struct IGDdatas * data,
279
281
  * \brief free the members of a UPNPUrls struct
280
282
  *
281
283
  * All URLs buffers are freed and zeroed
282
- * \param[out] urls
284
+ * \param[out] urls URL structure to free
283
285
  */
284
286
  MINIUPNP_LIBSPEC void
285
287
  FreeUPNPUrls(struct UPNPUrls * urls);
@@ -14,19 +14,14 @@
14
14
  * Use unsigned long long when available :
15
15
  * strtoull is C99
16
16
  *
17
- * \def STRTOUI
18
- * \brief strtoull() if available, strtol() if not
19
- * \todo should not be in the public API
20
17
  * \def UNSIGNED_INTEGER
21
18
  * \brief `unsigned long long` or `unsigned int`
19
+ * \todo int can be 16 bits, so it should be `unsigned long`
22
20
  */
23
21
  #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
24
22
  #define UNSIGNED_INTEGER unsigned long long
25
- #define STRTOUI strtoull
26
23
  #else
27
24
  #define UNSIGNED_INTEGER unsigned int
28
- #define STRTOUI strtoul
29
25
  #endif
30
26
 
31
27
  #endif
32
-
@@ -47,31 +47,6 @@ MINIUPNP_LIBSPEC void * miniwget_getaddr(const char * url, int * size,
47
47
  char * addr, int addrlen,
48
48
  unsigned int scope_id, int * status_code);
49
49
 
50
- /*! \brief parse a HTTP URL
51
- *
52
- * URL formats supported :
53
- * - `http://192.168.1.1/path/xxx`
54
- * - `http://192.168.1.1:8080/path/xxx`
55
- * - `http://[2a00:1234:5678:90ab::123]/path/xxx`
56
- * - `http://[2a00:1234:5678:90ab::123]:8080/path/xxx`
57
- * - `http://[fe80::1234:5678:90ab%%eth0]/path/xxx`
58
- * - `http://[fe80::1234:5678:90ab%%eth0]:8080/path/xxx`
59
- *
60
- * `%` may be encoded as `%25`
61
- *
62
- * \todo should probably not be exposed in the public API
63
- * \param[in] url URL to parse
64
- * \param[out] hostname hostname part of the URL (size of MAXHOSTNAMELEN+1)
65
- * \param[out] port set to the port specified in the URL or 80
66
- * \param[out] path set to the begining of the path part of the URL
67
- * \param[out] scope_id set to the interface id if specified in the
68
- * link-local IPv6 address
69
- * \return 0 for failure, 1 for success
70
- */
71
- int parseURL(const char * url,
72
- char * hostname, unsigned short * port, char * * path,
73
- unsigned int * scope_id);
74
-
75
50
  #ifdef __cplusplus
76
51
  }
77
52
  #endif
@@ -1,4 +1,4 @@
1
- /* $Id: upnpcommands.h,v 1.34 2025/02/08 23:15:17 nanard Exp $ */
1
+ /* $Id: upnpcommands.h,v 1.36 2025/03/18 23:40:15 nanard Exp $ */
2
2
  /* vim: tabstop=4 shiftwidth=4 noexpandtab
3
3
  * Project: miniupnp
4
4
  * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
@@ -360,6 +360,44 @@ UPNP_GetSpecificPortMappingEntry(const char * controlURL,
360
360
  char * enabled,
361
361
  char * leaseDuration);
362
362
 
363
+ /*! \brief retrieves an existing port mapping for a port:protocol
364
+ *
365
+ * List of possible UPnP errors for UPNP_GetSpecificPortMappingEntry() :
366
+ * errorCode errorDescription (short) | Description (long)
367
+ * ---------------------------------- | ------------------
368
+ * 402 Invalid Args | See UPnP Device Architecture section on Control.
369
+ * 501 Action Failed | See UPnP Device Architecture section on Control.
370
+ * 606 Action not authorized | The action requested REQUIRES authorization and the sender was not authorized.
371
+ * 714 NoSuchEntryInArray | The specified value does not exist in the array.
372
+ *
373
+ * \param[in] controlURL controlURL of the WANIPConnection of a WANConnectionDevice
374
+ * \param[in] servicetype urn:schemas-upnp-org:service:WANIPConnection:1
375
+ * \param[in] extPort External port
376
+ * \param[in] proto `TCP` or `UDP`
377
+ * \param[in] remoteHost IP or empty string for wildcard. Most IGD don't
378
+ * support it
379
+ * \param[out] intClient 16 bytes buffer
380
+ * \param[out] intPort 6 bytes buffer
381
+ * \param[out] desc desclen bytes buffer
382
+ * \param[in] desclen desc buffer length
383
+ * \param[out] enabled 4 bytes buffer
384
+ * \param[out] leaseDuration 16 bytes
385
+ * \return #UPNPCOMMAND_SUCCESS, #UPNPCOMMAND_INVALID_ARGS,
386
+ * #UPNPCOMMAND_UNKNOWN_ERROR or a UPnP Error Code.
387
+ */
388
+ MINIUPNP_LIBSPEC int
389
+ UPNP_GetSpecificPortMappingEntryExt(const char * controlURL,
390
+ const char * servicetype,
391
+ const char * extPort,
392
+ const char * proto,
393
+ const char * remoteHost,
394
+ char * intClient,
395
+ char * intPort,
396
+ char * desc,
397
+ size_t desclen,
398
+ char * enabled,
399
+ char * leaseDuration);
400
+
363
401
  /*! \brief WANIPConnection:GetGenericPortMappingEntry()
364
402
  *
365
403
  * errorCode errorDescription (short) | Description (long)
@@ -395,6 +433,45 @@ UPNP_GetGenericPortMappingEntry(const char * controlURL,
395
433
  char * rHost,
396
434
  char * duration);
397
435
 
436
+ /*! \brief WANIPConnection:GetGenericPortMappingEntry()
437
+ *
438
+ * errorCode errorDescription (short) | Description (long)
439
+ * ---------------------------------- | ------------------
440
+ * 402 Invalid Args | See UPnP Device Architecture section on Control.
441
+ * 606 Action not authorized | The action requested REQUIRES authorization and the sender was not authorized.
442
+ * 713 SpecifiedArrayIndexInvalid | The specified array index is out of bounds
443
+ *
444
+ * \param[in] controlURL controlURL of the WANIPConnection of a WANConnectionDevice
445
+ * \param[in] servicetype urn:schemas-upnp-org:service:WANIPConnection:1
446
+ * \param[in] index
447
+ * \param[out] extPort 6 bytes buffer
448
+ * \param[out] intClient 16 bytes buffer
449
+ * \param[out] intPort 6 bytes buffer
450
+ * \param[out] protocol 4 bytes buffer
451
+ * \param[out] desc desclen bytes buffer
452
+ * \param[in] desclen desc buffer length
453
+ * \param[out] enabled 4 bytes buffer
454
+ * \param[out] rHost desclen bytes buffer
455
+ * \param[in] rHostlen rHost buffer length
456
+ * \param[out] duration 16 bytes buffer
457
+ * \return #UPNPCOMMAND_SUCCESS, #UPNPCOMMAND_INVALID_ARGS,
458
+ * #UPNPCOMMAND_UNKNOWN_ERROR or a UPnP Error Code.
459
+ */
460
+ MINIUPNP_LIBSPEC int
461
+ UPNP_GetGenericPortMappingEntryExt(const char * controlURL,
462
+ const char * servicetype,
463
+ const char * index,
464
+ char * extPort,
465
+ char * intClient,
466
+ char * intPort,
467
+ char * protocol,
468
+ char * desc,
469
+ size_t desclen,
470
+ char * enabled,
471
+ char * rHost,
472
+ size_t rHostlen,
473
+ char * duration);
474
+
398
475
  /*! \brief retrieval of a list of existing port mappings
399
476
  *
400
477
  * Available in IGD v2 : WANIPConnection:GetListOfPortMappings()
@@ -1,4 +1,4 @@
1
- /* $Id: upnpreplyparse.h,v 1.20 2025/02/08 23:15:17 nanard Exp $ */
1
+ /* $Id: upnpreplyparse.h,v 1.22 2025/03/29 17:58:12 nanard Exp $ */
2
2
  /* MiniUPnP project
3
3
  * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
4
4
  * (c) 2006-2025 Thomas Bernard
@@ -16,17 +16,10 @@
16
16
  extern "C" {
17
17
  #endif
18
18
 
19
- /*! \brief Name/Value linked list
20
- * \todo should not be exposed in the public API
19
+ /*! \brief Name/Value linked list
20
+ * not exposed in the public API
21
21
  */
22
- struct NameValue {
23
- /*! \brief pointer to the next element */
24
- struct NameValue * l_next;
25
- /*! \brief name */
26
- char name[64];
27
- /*! \brief character value */
28
- char value[128];
29
- };
22
+ struct NameValue;
30
23
 
31
24
  /*! \brief data structure for parsing */
32
25
  struct NameValueParserData {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: miniupnpc
3
- Version: 2.3.1
3
+ Version: 2.3.3
4
4
  Summary: MiniUPnP IGD client
5
5
  Home-page: https://miniupnp.tuxfamily.org/
6
6
  Author: Thomas BERNARD
@@ -8,6 +8,7 @@
8
8
  * provided LICENSE file. */
9
9
  #ifdef _WIN32
10
10
  /* Win32 Specific includes and defines */
11
+ #define WIN32_LEAN_AND_MEAN
11
12
  #include <winsock2.h>
12
13
  #include <ws2tcpip.h>
13
14
  #if !defined(_MSC_VER)
@@ -1,8 +1,9 @@
1
- /* $Id: connecthostport.c,v 1.24 2020/11/09 19:26:53 nanard Exp $ */
1
+ /* $Id: connecthostport.c,v 1.25 2025/05/24 15:59:08 nanard Exp $ */
2
2
  /* vim: tabstop=4 shiftwidth=4 noexpandtab
3
3
  * Project : miniupnp
4
+ * Web : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
4
5
  * Author : Thomas Bernard
5
- * Copyright (c) 2010-2020 Thomas Bernard
6
+ * Copyright (c) 2010-2025 Thomas Bernard
6
7
  * This software is subject to the conditions detailed in the
7
8
  * LICENCE file provided in this distribution. */
8
9
 
@@ -15,6 +16,7 @@
15
16
  #include <string.h>
16
17
  #include <stdio.h>
17
18
  #ifdef _WIN32
19
+ #define WIN32_LEAN_AND_MEAN
18
20
  #include <winsock2.h>
19
21
  #include <ws2tcpip.h>
20
22
  #include <io.h>
@@ -123,8 +125,12 @@ SOCKET connecthostport(const char * host, unsigned short port,
123
125
  #else
124
126
  n = select(s + 1, NULL, &wset, NULL, NULL);
125
127
  #endif
126
- if(n == -1 && errno == EINTR)
127
- continue;
128
+ if(n < 0) {
129
+ if (errno == EINTR)
130
+ continue; /* try again */
131
+ else
132
+ break; /* EBADF, EFAULT, EINVAL */
133
+ }
128
134
  #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT
129
135
  if(n == 0) {
130
136
  errno = ETIMEDOUT;
@@ -132,8 +138,6 @@ SOCKET connecthostport(const char * host, unsigned short port,
132
138
  break;
133
139
  }
134
140
  #endif
135
- /*len = 0;*/
136
- /*n = getpeername(s, NULL, &len);*/
137
141
  len = sizeof(err);
138
142
  if(getsockopt(s, SOL_SOCKET, SO_ERROR, &err, &len) < 0) {
139
143
  PRINT_SOCKET_ERROR("getsockopt");
@@ -240,8 +244,12 @@ SOCKET connecthostport(const char * host, unsigned short port,
240
244
  #else
241
245
  n = select(s + 1, NULL, &wset, NULL, NULL);
242
246
  #endif
243
- if(n == -1 && errno == EINTR)
244
- continue;
247
+ if(n < 0) {
248
+ if (errno == EINTR)
249
+ continue; /* try again */
250
+ else
251
+ break; /* EBADF, EFAULT, EINVAL */
252
+ }
245
253
  #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT
246
254
  if(n == 0) {
247
255
  errno = ETIMEDOUT;
@@ -249,8 +257,6 @@ SOCKET connecthostport(const char * host, unsigned short port,
249
257
  break;
250
258
  }
251
259
  #endif
252
- /*len = 0;*/
253
- /*n = getpeername(s, NULL, &len);*/
254
260
  len = sizeof(err);
255
261
  if(getsockopt(s, SOL_SOCKET, SO_ERROR, &err, &len) < 0) {
256
262
  PRINT_SOCKET_ERROR("getsockopt");
@@ -1,8 +1,8 @@
1
- /* $Id: minisoap.c,v 1.32 2023/07/05 22:43:50 nanard Exp $ */
1
+ /* $Id: minisoap.c,v 1.35 2025/04/27 21:13:45 nanard Exp $ */
2
2
  /* vim: tabstop=4 shiftwidth=4 noexpandtab
3
3
  * Project : miniupnp
4
4
  * Author : Thomas Bernard
5
- * Copyright (c) 2005-2024 Thomas Bernard
5
+ * Copyright (c) 2005-2025 Thomas Bernard
6
6
  * This software is subject to the conditions detailed in the
7
7
  * LICENCE file provided in this distribution.
8
8
  *
@@ -11,6 +11,7 @@
11
11
  #include <stdio.h>
12
12
  #include <string.h>
13
13
  #ifdef _WIN32
14
+ #define WIN32_LEAN_AND_MEAN
14
15
  #include <io.h>
15
16
  #include <winsock2.h>
16
17
  #include "win32_snprintf.h"
@@ -99,7 +100,6 @@ int soapPostSubmit(SOCKET fd,
99
100
  #endif
100
101
  "SOAPAction: \"%s\"\r\n"
101
102
  "Connection: close\r\n"
102
- "Cache-Control: no-cache\r\n" /* ??? */
103
103
  "\r\n",
104
104
  url, httpversion, host, portstr, bodysize, action);
105
105
  if ((unsigned int)headerssize >= sizeof(headerbuf))
@@ -1,4 +1,4 @@
1
- /* $Id: minissdpc.c,v 1.52 2025/01/12 15:47:17 nanard Exp $ */
1
+ /* $Id: minissdpc.c,v 1.54 2025/03/29 17:59:01 nanard Exp $ */
2
2
  /* vim: tabstop=4 shiftwidth=4 noexpandtab
3
3
  * Project : miniupnp
4
4
  * Web : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
@@ -16,6 +16,7 @@
16
16
  #endif
17
17
  #if defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__)
18
18
  #ifdef _WIN32
19
+ #define WIN32_LEAN_AND_MEAN
19
20
  #include <winsock2.h>
20
21
  #include <ws2tcpip.h>
21
22
  #include <io.h>
@@ -390,7 +391,7 @@ free_tmp_and_return:
390
391
  * the last 4 arguments are filled during the parsing :
391
392
  * - location/locationsize : "location:" field of the SSDP reply packet
392
393
  * - st/stsize : "st:" field of the SSDP reply packet.
393
- * - usn/usnsize : "usn:" filed of the SSDP reply packet
394
+ * - usn/usnsize : "usn:" field of the SSDP reply packet
394
395
  * The strings are NOT null terminated */
395
396
  static void
396
397
  parseMSEARCHReply(const char * reply, int size,
@@ -542,10 +543,10 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
542
543
  int n;
543
544
  struct sockaddr_storage sockudp_r;
544
545
  unsigned int mx;
546
+ int rv;
545
547
  #ifdef NO_GETADDRINFO
546
548
  struct sockaddr_storage sockudp_w;
547
549
  #else
548
- int rv;
549
550
  struct addrinfo hints, *servinfo;
550
551
  #endif
551
552
  #ifdef _WIN32
@@ -874,9 +875,9 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
874
875
  p->sin_port = htons(SSDP_PORT);
875
876
  p->sin_addr.s_addr = inet_addr(UPNP_MCAST_ADDR);
876
877
  }
877
- n = sendto(sudp, bufr, n, 0, &sockudp_w,
878
- ipv6 ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in));
879
- if (n < 0) {
878
+ rv = sendto(sudp, bufr, n, 0, (struct sockaddr *)&sockudp_w,
879
+ ipv6 ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in));
880
+ if (rv < 0) {
880
881
  if(error)
881
882
  *error = MINISSDPC_SOCKET_ERROR;
882
883
  PRINT_SOCKET_ERROR("sendto");
@@ -902,9 +903,11 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
902
903
  break;
903
904
  } else {
904
905
  struct addrinfo *p;
906
+ /* as getaddrinfo() returns a linked list, we are iterating it
907
+ * even thought it should only return one result here */
905
908
  for(p = servinfo; p; p = p->ai_next) {
906
- n = sendto(sudp, bufr, n, 0, p->ai_addr, MSC_CAST_INT p->ai_addrlen);
907
- if (n < 0) {
909
+ rv = sendto(sudp, bufr, n, 0, p->ai_addr, MSC_CAST_INT p->ai_addrlen);
910
+ if (rv < 0) {
908
911
  #ifdef DEBUG
909
912
  char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
910
913
  if (getnameinfo(p->ai_addr, (socklen_t)p->ai_addrlen, hbuf, sizeof(hbuf), sbuf,
@@ -11,6 +11,7 @@
11
11
  #include <string.h>
12
12
  #ifdef _WIN32
13
13
  /* Win32 Specific includes and defines */
14
+ #define WIN32_LEAN_AND_MEAN
14
15
  #include <winsock2.h>
15
16
  #include <ws2tcpip.h>
16
17
  #include <io.h>
@@ -1,8 +1,8 @@
1
- /* $Id: miniwget.c,v 1.85 2023/06/15 21:47:50 nanard Exp $ */
1
+ /* $Id: miniwget.c,v 1.88 2025/05/25 21:56:49 nanard Exp $ */
2
2
  /* Project : miniupnp
3
3
  * Website : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
4
4
  * Author : Thomas Bernard
5
- * Copyright (c) 2005-2024 Thomas Bernard
5
+ * Copyright (c) 2005-2025 Thomas Bernard
6
6
  * This software is subject to the conditions detailed in the
7
7
  * LICENCE file provided in this distribution. */
8
8
 
@@ -11,6 +11,7 @@
11
11
  #include <string.h>
12
12
  #include <ctype.h>
13
13
  #ifdef _WIN32
14
+ #define WIN32_LEAN_AND_MEAN
14
15
  #include <winsock2.h>
15
16
  #include <ws2tcpip.h>
16
17
  #include <io.h>
@@ -0,0 +1,54 @@
1
+ /* $Id: miniwget_private.h,v 1.1 2018/04/06 10:17:58 nanard Exp $ */
2
+ /* Project : miniupnp
3
+ * Author : Thomas Bernard
4
+ * Copyright (c) 2018-2025 Thomas Bernard
5
+ * This software is subject to the conditions detailed in the
6
+ * LICENCE file provided in this distribution.
7
+ * */
8
+ #ifndef MINIWGET_INTERNAL_H_INCLUDED
9
+ #define MINIWGET_INTERNAL_H_INCLUDED
10
+
11
+ /*! \file miniwget_private.h
12
+ * \brief Lightweight HTTP client private API
13
+ */
14
+ #include "miniupnpc_socketdef.h"
15
+
16
+ /*! \brief Read a HTTP response from a socket
17
+ *
18
+ * Processed HTTP headers :
19
+ * - `Content-Length`
20
+ * - `Transfer-encoding`
21
+ * return a pointer to the content buffer, which length is saved
22
+ * to the length parameter.
23
+ * \param[in] s socket
24
+ * \param[out] size returned content buffer size
25
+ * \param[out] status_code HTTP Status code
26
+ * \return malloc'ed content buffer
27
+ */
28
+ void * getHTTPResponse(SOCKET s, int * size, int * status_code);
29
+
30
+ /*! \brief parse a HTTP URL
31
+ *
32
+ * URL formats supported :
33
+ * - `http://192.168.1.1/path/xxx`
34
+ * - `http://192.168.1.1:8080/path/xxx`
35
+ * - `http://[2a00:1234:5678:90ab::123]/path/xxx`
36
+ * - `http://[2a00:1234:5678:90ab::123]:8080/path/xxx`
37
+ * - `http://[fe80::1234:5678:90ab%%eth0]/path/xxx`
38
+ * - `http://[fe80::1234:5678:90ab%%eth0]:8080/path/xxx`
39
+ *
40
+ * `%` may be encoded as `%25`
41
+ *
42
+ * \param[in] url URL to parse
43
+ * \param[out] hostname hostname part of the URL (size of MAXHOSTNAMELEN+1)
44
+ * \param[out] port set to the port specified in the URL or 80
45
+ * \param[out] path set to the begining of the path part of the URL
46
+ * \param[out] scope_id set to the interface id if specified in the
47
+ * link-local IPv6 address
48
+ * \return 0 for failure, 1 for success
49
+ */
50
+ int parseURL(const char * url,
51
+ char * hostname, unsigned short * port, char * * path,
52
+ unsigned int * scope_id);
53
+
54
+ #endif
@@ -1,7 +1,7 @@
1
- /* $Id: portlistingparse.c,v 1.9 2015/07/15 12:41:13 nanard Exp $ */
1
+ /* $Id: portlistingparse.c,v 1.12 2025/03/29 17:58:33 nanard Exp $ */
2
2
  /* MiniUPnP project
3
- * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
4
- * (c) 2011-2020 Thomas Bernard
3
+ * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
4
+ * (c) 2011-2025 Thomas Bernard
5
5
  * This software is subject to the conditions detailed
6
6
  * in the LICENCE file provided within the distribution */
7
7
  #include <string.h>
@@ -15,7 +15,7 @@
15
15
  #if defined(__HAIKU__)
16
16
  /* rename our private function because Haiku already defines a atoui() function */
17
17
  #define atoui atoui2
18
- #endif
18
+ #endif
19
19
 
20
20
  /* list of the elements */
21
21
  static const struct {
@@ -1,14 +1,15 @@
1
- /* $Id: receivedata.c,v 1.10 2021/03/02 23:33:07 nanard Exp $ */
1
+ /* $Id: receivedata.c,v 1.11 2025/05/25 21:56:49 nanard Exp $ */
2
2
  /* Project : miniupnp
3
3
  * Website : http://miniupnp.free.fr/
4
4
  * Author : Thomas Bernard
5
- * Copyright (c) 2011-2021 Thomas Bernard
5
+ * Copyright (c) 2011-2025 Thomas Bernard
6
6
  * This software is subject to the conditions detailed in the
7
7
  * LICENCE file provided in this distribution. */
8
8
 
9
9
  #include <stdio.h>
10
10
  #include <string.h>
11
11
  #ifdef _WIN32
12
+ #define WIN32_LEAN_AND_MEAN
12
13
  #include <winsock2.h>
13
14
  #include <ws2tcpip.h>
14
15
  #else /* _WIN32 */
@@ -1,4 +1,4 @@
1
- /* $Id: upnpcommands.c,v 1.53 2025/02/23 15:31:26 nanard Exp $ */
1
+ /* $Id: upnpcommands.c,v 1.56 2025/03/29 18:08:59 nanard Exp $ */
2
2
  /* vim: tabstop=4 shiftwidth=4 noexpandtab
3
3
  * Project : miniupnp
4
4
  * Author : Thomas Bernard
@@ -14,6 +14,17 @@
14
14
  #include "portlistingparse.h"
15
15
  #include "upnpreplyparse.h"
16
16
 
17
+ /*! \file upnpcommands.c
18
+ * \brief Internet Gateway Device methods implementations
19
+ * \def STRTOUI
20
+ * \brief strtoull() if available, strtol() if not
21
+ */
22
+ #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
23
+ #define STRTOUI strtoull
24
+ #else
25
+ #define STRTOUI strtoul
26
+ #endif
27
+
17
28
  static UNSIGNED_INTEGER
18
29
  my_atoui(const char * s)
19
30
  {
@@ -158,9 +169,7 @@ UPNP_GetStatusInfo(const char * controlURL,
158
169
  }
159
170
 
160
171
  if(uptime) {
161
- if(up)
162
- sscanf(up,"%u",uptime);
163
- else
172
+ if(!up || sscanf(up,"%u",uptime) != 1)
164
173
  *uptime = 0;
165
174
  }
166
175
 
@@ -174,8 +183,8 @@ UPNP_GetStatusInfo(const char * controlURL,
174
183
 
175
184
  p = GetValueFromNameValueList(&pdata, "errorCode");
176
185
  if(p) {
177
- ret = UPNPCOMMAND_UNKNOWN_ERROR;
178
- sscanf(p, "%d", &ret);
186
+ if(sscanf(p, "%d", &ret) != 1)
187
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
179
188
  }
180
189
  ClearNameValueList(&pdata);
181
190
  return ret;
@@ -214,8 +223,8 @@ UPNP_GetConnectionTypeInfo(const char * controlURL,
214
223
  connectionType[0] = '\0';
215
224
  p = GetValueFromNameValueList(&pdata, "errorCode");
216
225
  if(p) {
217
- ret = UPNPCOMMAND_UNKNOWN_ERROR;
218
- sscanf(p, "%d", &ret);
226
+ if(sscanf(p, "%d", &ret) != 1)
227
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
219
228
  }
220
229
  ClearNameValueList(&pdata);
221
230
  return ret;
@@ -262,22 +271,18 @@ UPNP_GetLinkLayerMaxBitRates(const char * controlURL,
262
271
  ret = UPNPCOMMAND_SUCCESS;
263
272
 
264
273
  if(bitrateDown) {
265
- if(down)
266
- sscanf(down,"%u",bitrateDown);
267
- else
274
+ if(!down || sscanf(down,"%u",bitrateDown) != 1)
268
275
  *bitrateDown = 0;
269
276
  }
270
277
 
271
278
  if(bitrateUp) {
272
- if(up)
273
- sscanf(up,"%u",bitrateUp);
274
- else
279
+ if(!up || sscanf(up,"%u",bitrateUp) != 1)
275
280
  *bitrateUp = 0;
276
281
  }
277
282
  p = GetValueFromNameValueList(&pdata, "errorCode");
278
283
  if(p) {
279
- ret = UPNPCOMMAND_UNKNOWN_ERROR;
280
- sscanf(p, "%d", &ret);
284
+ if(sscanf(p, "%d", &ret) != 1)
285
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
281
286
  }
282
287
  ClearNameValueList(&pdata);
283
288
  return ret;
@@ -327,8 +332,8 @@ UPNP_GetExternalIPAddress(const char * controlURL,
327
332
 
328
333
  p = GetValueFromNameValueList(&pdata, "errorCode");
329
334
  if(p) {
330
- ret = UPNPCOMMAND_UNKNOWN_ERROR;
331
- sscanf(p, "%d", &ret);
335
+ if(sscanf(p, "%d", &ret) != 1)
336
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
332
337
  }
333
338
 
334
339
  ClearNameValueList(&pdata);
@@ -379,8 +384,8 @@ UPNP_AddPortMapping(const char * controlURL, const char * servicetype,
379
384
  resVal = GetValueFromNameValueList(&pdata, "errorCode");
380
385
  if(resVal) {
381
386
  /*printf("AddPortMapping errorCode = '%s'\n", resVal); */
382
- ret = UPNPCOMMAND_UNKNOWN_ERROR;
383
- sscanf(resVal, "%d", &ret);
387
+ if(sscanf(resVal, "%d", &ret) != 1)
388
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
384
389
  } else {
385
390
  ret = UPNPCOMMAND_SUCCESS;
386
391
  }
@@ -416,7 +421,7 @@ UPNP_AddAnyPortMapping(const char * controlURL, const char * servicetype,
416
421
  const char * resVal;
417
422
  int ret;
418
423
 
419
- if(!inPort || !inClient || !proto || !extPort)
424
+ if(!inPort || !inClient || !proto || !extPort || !reservedPort)
420
425
  return UPNPCOMMAND_INVALID_ARGS;
421
426
  buffer = simpleUPnPcommand(controlURL, servicetype,
422
427
  "AddAnyPortMapping", AddAnyPortMappingArgs,
@@ -428,8 +433,8 @@ UPNP_AddAnyPortMapping(const char * controlURL, const char * servicetype,
428
433
  free(buffer);
429
434
  resVal = GetValueFromNameValueList(&pdata, "errorCode");
430
435
  if(resVal) {
431
- ret = UPNPCOMMAND_UNKNOWN_ERROR;
432
- sscanf(resVal, "%d", &ret);
436
+ if(sscanf(resVal, "%d", &ret) != 1)
437
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
433
438
  } else {
434
439
  char *p;
435
440
 
@@ -478,8 +483,8 @@ UPNP_DeletePortMapping(const char * controlURL, const char * servicetype,
478
483
  free(buffer);
479
484
  resVal = GetValueFromNameValueList(&pdata, "errorCode");
480
485
  if(resVal) {
481
- ret = UPNPCOMMAND_UNKNOWN_ERROR;
482
- sscanf(resVal, "%d", &ret);
486
+ if(sscanf(resVal, "%d", &ret) != 1)
487
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
483
488
  } else {
484
489
  ret = UPNPCOMMAND_SUCCESS;
485
490
  }
@@ -520,8 +525,8 @@ UPNP_DeletePortMappingRange(const char * controlURL, const char * servicetype,
520
525
  free(buffer);
521
526
  resVal = GetValueFromNameValueList(&pdata, "errorCode");
522
527
  if(resVal) {
523
- ret = UPNPCOMMAND_UNKNOWN_ERROR;
524
- sscanf(resVal, "%d", &ret);
528
+ if(sscanf(resVal, "%d", &ret) != 1)
529
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
525
530
  } else {
526
531
  ret = UPNPCOMMAND_SUCCESS;
527
532
  }
@@ -532,15 +537,36 @@ UPNP_DeletePortMappingRange(const char * controlURL, const char * servicetype,
532
537
  MINIUPNP_LIBSPEC int
533
538
  UPNP_GetGenericPortMappingEntry(const char * controlURL,
534
539
  const char * servicetype,
535
- const char * index,
536
- char * extPort,
537
- char * intClient,
538
- char * intPort,
539
- char * protocol,
540
- char * desc,
541
- char * enabled,
542
- char * rHost,
543
- char * duration)
540
+ const char * index,
541
+ char * extPort,
542
+ char * intClient,
543
+ char * intPort,
544
+ char * protocol,
545
+ char * desc,
546
+ char * enabled,
547
+ char * rHost,
548
+ char * duration)
549
+ {
550
+ return UPNP_GetGenericPortMappingEntryExt(controlURL, servicetype, index,
551
+ extPort, intClient, intPort,
552
+ protocol, desc, 80, enabled,
553
+ rHost, 64, duration);
554
+ }
555
+
556
+ MINIUPNP_LIBSPEC int
557
+ UPNP_GetGenericPortMappingEntryExt(const char * controlURL,
558
+ const char * servicetype,
559
+ const char * index,
560
+ char * extPort,
561
+ char * intClient,
562
+ char * intPort,
563
+ char * protocol,
564
+ char * desc,
565
+ size_t desclen,
566
+ char * enabled,
567
+ char * rHost,
568
+ size_t rHostlen,
569
+ char * duration)
544
570
  {
545
571
  struct NameValueParserData pdata;
546
572
  struct UPNParg GetPortMappingArgs[] = {
@@ -550,11 +576,9 @@ UPNP_GetGenericPortMappingEntry(const char * controlURL,
550
576
  char * buffer;
551
577
  int bufsize;
552
578
  char * p;
553
- int r = UPNPCOMMAND_UNKNOWN_ERROR;
554
- if(!index)
579
+ int ret = UPNPCOMMAND_UNKNOWN_ERROR;
580
+ if(!index || !extPort || !intClient || !intPort || !protocol)
555
581
  return UPNPCOMMAND_INVALID_ARGS;
556
- intClient[0] = '\0';
557
- intPort[0] = '\0';
558
582
  buffer = simpleUPnPcommand(controlURL, servicetype,
559
583
  "GetGenericPortMappingEntry",
560
584
  GetPortMappingArgs, &bufsize);
@@ -567,28 +591,40 @@ UPNP_GetGenericPortMappingEntry(const char * controlURL,
567
591
  p = GetValueFromNameValueList(&pdata, "NewRemoteHost");
568
592
  if(p && rHost)
569
593
  {
570
- strncpy(rHost, p, 64);
571
- rHost[63] = '\0';
594
+ strncpy(rHost, p, rHostlen);
595
+ rHost[rHostlen-1] = '\0';
572
596
  }
573
597
  p = GetValueFromNameValueList(&pdata, "NewExternalPort");
574
- if(p && extPort)
598
+ if(p)
575
599
  {
576
600
  strncpy(extPort, p, 6);
577
601
  extPort[5] = '\0';
578
- r = UPNPCOMMAND_SUCCESS;
602
+ ret = UPNPCOMMAND_SUCCESS;
603
+ }
604
+ else
605
+ {
606
+ extPort[0] = '\0';
579
607
  }
580
608
  p = GetValueFromNameValueList(&pdata, "NewProtocol");
581
- if(p && protocol)
609
+ if(p)
582
610
  {
583
611
  strncpy(protocol, p, 4);
584
612
  protocol[3] = '\0';
585
613
  }
614
+ else
615
+ {
616
+ protocol[0] = '\0';
617
+ }
586
618
  p = GetValueFromNameValueList(&pdata, "NewInternalClient");
587
619
  if(p)
588
620
  {
589
621
  strncpy(intClient, p, 16);
590
622
  intClient[15] = '\0';
591
- r = 0;
623
+ ret = 0;
624
+ }
625
+ else
626
+ {
627
+ intClient[0] = '\0';
592
628
  }
593
629
  p = GetValueFromNameValueList(&pdata, "NewInternalPort");
594
630
  if(p)
@@ -596,6 +632,10 @@ UPNP_GetGenericPortMappingEntry(const char * controlURL,
596
632
  strncpy(intPort, p, 6);
597
633
  intPort[5] = '\0';
598
634
  }
635
+ else
636
+ {
637
+ intPort[0] = '\0';
638
+ }
599
639
  p = GetValueFromNameValueList(&pdata, "NewEnabled");
600
640
  if(p && enabled)
601
641
  {
@@ -605,8 +645,8 @@ UPNP_GetGenericPortMappingEntry(const char * controlURL,
605
645
  p = GetValueFromNameValueList(&pdata, "NewPortMappingDescription");
606
646
  if(p && desc)
607
647
  {
608
- strncpy(desc, p, 80);
609
- desc[79] = '\0';
648
+ strncpy(desc, p, desclen);
649
+ desc[desclen-1] = '\0';
610
650
  }
611
651
  p = GetValueFromNameValueList(&pdata, "NewLeaseDuration");
612
652
  if(p && duration)
@@ -616,11 +656,11 @@ UPNP_GetGenericPortMappingEntry(const char * controlURL,
616
656
  }
617
657
  p = GetValueFromNameValueList(&pdata, "errorCode");
618
658
  if(p) {
619
- r = UPNPCOMMAND_UNKNOWN_ERROR;
620
- sscanf(p, "%d", &r);
659
+ if(sscanf(p, "%d", &ret) != 1)
660
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
621
661
  }
622
662
  ClearNameValueList(&pdata);
623
- return r;
663
+ return ret;
624
664
  }
625
665
 
626
666
  MINIUPNP_LIBSPEC int
@@ -653,8 +693,8 @@ UPNP_GetPortMappingNumberOfEntries(const char * controlURL,
653
693
 
654
694
  p = GetValueFromNameValueList(&pdata, "errorCode");
655
695
  if(p) {
656
- ret = UPNPCOMMAND_UNKNOWN_ERROR;
657
- sscanf(p, "%d", &ret);
696
+ if(sscanf(p, "%d", &ret) != 1)
697
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
658
698
  }
659
699
 
660
700
  ClearNameValueList(&pdata);
@@ -675,6 +715,26 @@ UPNP_GetSpecificPortMappingEntry(const char * controlURL,
675
715
  char * desc,
676
716
  char * enabled,
677
717
  char * leaseDuration)
718
+ {
719
+ return UPNP_GetSpecificPortMappingEntryExt(controlURL, servicetype,
720
+ extPort, proto, remoteHost,
721
+ intClient, intPort,
722
+ desc, 80, enabled,
723
+ leaseDuration);
724
+ }
725
+
726
+ MINIUPNP_LIBSPEC int
727
+ UPNP_GetSpecificPortMappingEntryExt(const char * controlURL,
728
+ const char * servicetype,
729
+ const char * extPort,
730
+ const char * proto,
731
+ const char * remoteHost,
732
+ char * intClient,
733
+ char * intPort,
734
+ char * desc,
735
+ size_t desclen,
736
+ char * enabled,
737
+ char * leaseDuration)
678
738
  {
679
739
  struct NameValueParserData pdata;
680
740
  struct UPNParg GetPortMappingArgs[] = {
@@ -724,8 +784,8 @@ UPNP_GetSpecificPortMappingEntry(const char * controlURL,
724
784
 
725
785
  p = GetValueFromNameValueList(&pdata, "NewPortMappingDescription");
726
786
  if(p && desc) {
727
- strncpy(desc, p, 80);
728
- desc[79] = '\0';
787
+ strncpy(desc, p, desclen);
788
+ desc[desclen-1] = '\0';
729
789
  }
730
790
 
731
791
  p = GetValueFromNameValueList(&pdata, "NewLeaseDuration");
@@ -737,8 +797,8 @@ UPNP_GetSpecificPortMappingEntry(const char * controlURL,
737
797
 
738
798
  p = GetValueFromNameValueList(&pdata, "errorCode");
739
799
  if(p) {
740
- ret = UPNPCOMMAND_UNKNOWN_ERROR;
741
- sscanf(p, "%d", &ret);
800
+ if(sscanf(p, "%d", &ret) != 1)
801
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
742
802
  }
743
803
 
744
804
  ClearNameValueList(&pdata);
@@ -818,8 +878,8 @@ UPNP_GetListOfPortMappings(const char * controlURL,
818
878
 
819
879
  p = GetValueFromNameValueList(&pdata, "errorCode");
820
880
  if(p) {
821
- ret = UPNPCOMMAND_UNKNOWN_ERROR;
822
- sscanf(p, "%d", &ret);
881
+ if(sscanf(p, "%d", &ret) != 1)
882
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
823
883
  }
824
884
  ClearNameValueList(&pdata);
825
885
 
@@ -866,8 +926,8 @@ UPNP_GetFirewallStatus(const char * controlURL,
866
926
  p = GetValueFromNameValueList(&pdata, "errorCode");
867
927
  if(p)
868
928
  {
869
- ret = UPNPCOMMAND_UNKNOWN_ERROR;
870
- sscanf(p, "%d", &ret);
929
+ if(sscanf(p, "%d", &ret) != 1)
930
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
871
931
  }
872
932
  ClearNameValueList(&pdata);
873
933
  return ret;
@@ -908,8 +968,8 @@ UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype
908
968
  resVal = GetValueFromNameValueList(&pdata, "errorCode");
909
969
  if(resVal)
910
970
  {
911
- ret = UPNPCOMMAND_UNKNOWN_ERROR;
912
- sscanf(resVal, "%d", &ret);
971
+ if(sscanf(resVal, "%d", &ret) != 1)
972
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
913
973
  }
914
974
  else
915
975
  {
@@ -973,8 +1033,8 @@ UPNP_AddPinhole(const char * controlURL, const char * servicetype,
973
1033
  if(resVal)
974
1034
  {
975
1035
  /*printf("AddPortMapping errorCode = '%s'\n", resVal);*/
976
- ret = UPNPCOMMAND_UNKNOWN_ERROR;
977
- sscanf(resVal, "%d", &ret);
1036
+ if(sscanf(resVal, "%d", &ret) != 1)
1037
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
978
1038
  }
979
1039
  else
980
1040
  {
@@ -1013,8 +1073,8 @@ UPNP_UpdatePinhole(const char * controlURL, const char * servicetype,
1013
1073
  if(resVal)
1014
1074
  {
1015
1075
  /*printf("AddPortMapping errorCode = '%s'\n", resVal); */
1016
- ret = UPNPCOMMAND_UNKNOWN_ERROR;
1017
- sscanf(resVal, "%d", &ret);
1076
+ if(sscanf(resVal, "%d", &ret) != 1)
1077
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
1018
1078
  }
1019
1079
  else
1020
1080
  {
@@ -1051,8 +1111,8 @@ UPNP_DeletePinhole(const char * controlURL, const char * servicetype, const char
1051
1111
  resVal = GetValueFromNameValueList(&pdata, "errorCode");
1052
1112
  if(resVal)
1053
1113
  {
1054
- ret = UPNPCOMMAND_UNKNOWN_ERROR;
1055
- sscanf(resVal, "%d", &ret);
1114
+ if(sscanf(resVal, "%d", &ret) != 1)
1115
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
1056
1116
  }
1057
1117
  else
1058
1118
  {
@@ -1100,8 +1160,8 @@ UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype,
1100
1160
  p = GetValueFromNameValueList(&pdata, "errorCode");
1101
1161
  if(p)
1102
1162
  {
1103
- ret = UPNPCOMMAND_UNKNOWN_ERROR;
1104
- sscanf(p, "%d", &ret);
1163
+ if(sscanf(p, "%d", &ret) != 1)
1164
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
1105
1165
  }
1106
1166
 
1107
1167
  ClearNameValueList(&pdata);
@@ -1142,8 +1202,8 @@ UPNP_GetPinholePackets(const char * controlURL, const char * servicetype,
1142
1202
  p = GetValueFromNameValueList(&pdata, "errorCode");
1143
1203
  if(p)
1144
1204
  {
1145
- ret = UPNPCOMMAND_UNKNOWN_ERROR;
1146
- sscanf(p, "%d", &ret);
1205
+ if(sscanf(p, "%d", &ret) != 1)
1206
+ ret = UPNPCOMMAND_UNKNOWN_ERROR;
1147
1207
  }
1148
1208
 
1149
1209
  ClearNameValueList(&pdata);
@@ -13,6 +13,23 @@
13
13
  #include "upnpreplyparse.h"
14
14
  #include "minixml.h"
15
15
 
16
+ struct NameValue {
17
+ /*! \brief pointer to the next element */
18
+ struct NameValue * l_next;
19
+ /*! \brief name */
20
+ char name[64];
21
+ #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
22
+ /* C99 flexible array member */
23
+ /*! \brief character value */
24
+ char value[];
25
+ #elif defined(__GNUC__)
26
+ char value[0];
27
+ #else
28
+ /* Fallback to a hack */
29
+ char value[1];
30
+ #endif
31
+ };
32
+
16
33
  static void
17
34
  NameValueParserStartElt(void * d, const char * name, int l)
18
35
  {
@@ -40,7 +57,7 @@ NameValueParserEndElt(void * d, const char * name, int namelen)
40
57
  int l;
41
58
  /* standard case. Limited to n chars strings */
42
59
  l = data->cdatalen;
43
- nv = malloc(sizeof(struct NameValue));
60
+ nv = malloc(sizeof(struct NameValue) + l + 1);
44
61
  if(nv == NULL)
45
62
  {
46
63
  /* malloc error */
@@ -50,8 +67,6 @@ NameValueParserEndElt(void * d, const char * name, int namelen)
50
67
  #endif /* DEBUG */
51
68
  return;
52
69
  }
53
- if(l>=(int)sizeof(nv->value))
54
- l = sizeof(nv->value) - 1;
55
70
  strncpy(nv->name, data->curelt, 64);
56
71
  nv->name[63] = '\0';
57
72
  if(data->cdata != NULL)
miniupnpc-2.3.1/VERSION DELETED
@@ -1 +0,0 @@
1
- 2.3.1
@@ -1,15 +0,0 @@
1
- /* $Id: miniwget_private.h,v 1.1 2018/04/06 10:17:58 nanard Exp $ */
2
- /* Project : miniupnp
3
- * Author : Thomas Bernard
4
- * Copyright (c) 2018 Thomas Bernard
5
- * This software is subject to the conditions detailed in the
6
- * LICENCE file provided in this distribution.
7
- * */
8
- #ifndef MINIWGET_INTERNAL_H_INCLUDED
9
- #define MINIWGET_INTERNAL_H_INCLUDED
10
-
11
- #include "miniupnpc_socketdef.h"
12
-
13
- void * getHTTPResponse(SOCKET s, int * size, int * status_code);
14
-
15
- #endif
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes