Commit Graph

550 Commits

Author SHA1 Message Date
Fabrice Fontaine
11f05dc09d Fix getaddrinfo() loop
Commit b116d10f did the following change:
    Use switch, int and sa_family_t with AF_INET in uri.c.

This breaks when getaddrinfo() only returns a single record, as in that
case the "break" only exits the switch statement and the loop-step
"res=res->ai_next" is still executed. After that "res == NULL" is
wrongly interpreted as not having found an AF_INET or AF_INET6 address.

Signed-off-by: Marcelo Roberto Jimenez <mroberto@users.sourceforge.net>
(cherry picked from commit faaef39a3c)
2014-09-22 11:36:10 -03:00
Peng
153d71f10b Fix memory leaks caused by DOMString members.
Signed-off-by: Marcelo Roberto Jimenez <mroberto@users.sourceforge.net>
2014-02-20 14:18:02 -03:00
Peng
c293ad00c4 rewrite soap_device.c
1) separate HTTP handling from SOAP handling
2) remove repeated validity check, each check is performed exactly once
3) fix HTTP status code per UPnP spec, SOAP spec and RFC 2774

Conflicts:
	ChangeLog
	upnp/src/soap/soap_device.c

Signed-off-by: Marcelo Roberto Jimenez <mroberto@users.sourceforge.net>
2014-02-20 14:15:35 -03:00
Peng
82cf12b9ed Fix several minor bugs in soap_device.c
1) remove redundant free
2) avoid user-provided ErrStr being overwritten by the default one
3) eliminated memory leak possiblity in handle_query_variable

Signed-off-by: Marcelo Roberto Jimenez <mroberto@users.sourceforge.net>
(cherry picked from commit bf60dc06e0)

Conflicts:
	upnp/src/soap/soap_device.c
2013-11-08 16:11:20 -02:00
Peng
a65f3cebb3 Fix return value check of parse_uri
Signed-off-by: Marcelo Roberto Jimenez <mroberto@users.sourceforge.net>
(cherry picked from commit 908785fba7)
2013-11-08 11:10:00 -02:00
Yoichi Nakayama
9a8758399c tv_ctrlpt crashes after detecting a later version of tvcontrol service
SF Bug Tracker #118, Creator: T.Iwamoto

	From:  gon3456@users.sf.net
	Steps to reproduce:
	1. Extracts and build libupnp-1.6.18
	$ tar -xjf /path/to/archive/libupnp-1.6.18.tar.bz2
	$ cd libupnp-1.6.18
	$ ./configure
	$ make
	2. Applies the attached patch and remake.
	$ patch -p1 < /path/to/patch/libupnp-1.6.18.patch
	$ make
	3. Run tv_device.
	$ cd upnp/sample
	$ ./tv_device
	4. Run tv_ctrlpt; the tv_ctrlpt crashes soon.
	$ ./tv_ctrlpt
	Segmentation fault (core dumped)
	This is an issue report about the sample program of control point.
	The tv_ctrlpt crashes after detecting a tvdevice that contains tvcontrol:2 or higher version of tvcontrol service.
	tv_ctrlpt should detect correctly such devices due to forward compatibility of control points with device.
	For more information about the compatibility, please refer the following document:
	DLNA Architectures and Protocols Part 1 2011 December - 7.3.2.1.3 (GUN:GZJXU)
	The attached patch changes the sample programs as below:
	- device: changes version of tvcontrol service from 1 to 2. This change may occur in the future.
	- cp: nothing changed: cp knows version 1 of tvcontrol service only.
	I know many vendors implements their control points based on the tv_ctrlpt, so I hope to fix this issue ASAP.

	==

	From: Yoichi NAKAYAMA
	SEGV is caused by strcpy with NULL argument.
	Attached patch will avoid SEGV in strcpy, but there may be other inconsistencies.

	> I know many vendors implements their control points based on the tv_ctrlpt,

	I don't think so. I think tv_ctrlpt is just a sample to be used with tv_device.

Signed-off-by: Marcelo Roberto Jimenez <mroberto@users.sourceforge.net>
(cherry picked from commit 1a28e8ff51)
2013-10-29 17:57:46 -02:00
Pino Toscano
89d34af3bd Fix compilation on GNU/Hurd
(cherry picked from commit 89ad5e6779)
2013-10-28 14:30:37 -02:00
Peng
4e87527eb6 Fix return value of http_RecvPostMessage and update httpparser.c's comments
(cherry picked from commit 062ac0c926)
2013-10-28 13:31:11 -02:00
Peng
a01cf2817a Fix return value of process_request and related subroutines
1) Only HTTP_XXX should be return
2) Make default return value work for process_request
(cherry picked from commit 06aa3b17c4)

Conflicts:
	upnp/src/genlib/net/http/webserver.c
2013-10-28 13:28:57 -02:00
Peng
4f630b1213 Fix Content-Range generation bug
(cherry picked from commit 9f444a680e)
2013-10-28 12:02:51 -02:00
zexian chen
c5777ae747 Fix memory leaks when when calling ThreadPoolAdd() or ThreadPoolAddPersistent()
Hi,

I had found some bugs about memory leak on libupnp-1.6.18.

It may lead to memory leak  when calling ThreadPoolAdd() or
ThreadPoolAddPersistent() which does not return 0.

See the attachment for patch.
(cherry picked from commit 8e3a71905b)

Conflicts:
	upnp/src/ssdp/ssdp_ctrlpt.c
2013-09-10 17:55:23 -03:00
Peng
490b0a5c86 Fix return value of config_description_doc.
UPNP_E_XXX should not be used instead of IXML_XXX
(cherry picked from commit 72c29ef1f6)
2013-09-04 11:20:11 -03:00
Peng
0c92ca4014 Remove faulty free in GetDescDocumentAndURL.
temp_str, which points to part of description, should not be freed.
(cherry picked from commit f6a3102b48)
2013-09-04 11:20:11 -03:00
Peng
1a8a8228e4 Avoid malicious client exploit to exhaust the device's memory
Suppose the UPnP device is listening on 192.168.1.102:49152. Use the following to send
garbage bytes to the device:
while true; do echo "\""; done | netcat 192.168.1.102 49152

The device just keeps receiving these bytes and its memory usage keeps growing.
Malicious client may exploit it to exhaust the device's memory.

The attached patch eliminates this possibility.
(cherry picked from commit 9a9c4e829e)
2013-09-02 14:57:37 -03:00
Peng
2c663643dd Scanner problems
1) restore the scanner's original cursor position in case of
   insufficient input;
2) free the memories allocated for a new header in case of a failure.
(cherry picked from commit 7a571f513e)
2013-09-02 14:50:05 -03:00
Peng
8bcc4b41d1 Patch to fix behaviou when char is signed
it seems to me that there is still something wrong:

	1)  the new is_qdtext_char() is incorrect.
	There is a trap if char is implemented as signed char.
	Suppose that c is '\xFF', it will be -1 when converted to an int.
	By definition, c should be qdtext:
	qdtext = <any TEXT except <">>
	TEXT = <any OCTET except CTLs, but including LWS>
	OCTET = <any 8-bit sequence of data>

	2) the character after '\\' could be either part of a quoted-pair
	(together with '\\'), or a normal qdtext, since '\\' itself can
	be treated as a qdtext. This is equivalent to saying that the
	character after '\\' in a quoted string could be ANY octet.

	A patch based on the above two observations is attached.

	Peng
(cherry picked from commit f10730f616)
2013-08-16 14:17:40 -03:00
Marcelo Roberto Jimenez
61d2950fa5 Enforce RFC 2616 and accept "0" after a backslash for quoted-strings.
Reported by Peng <howtofly(at)gmail.com>
(cherry picked from commit c70f5ce323)
2013-08-14 09:59:47 -03:00
Peng
cf8c0d0a93 scanner_get_token: robustness improvement
Patch to make scanner_get_token more robust (avoid over-reading).
(cherry picked from commit a3c540bc9b)
2013-08-14 09:59:47 -03:00
Marcelo Roberto Jimenez
e1813ed702 Merge remote-tracking branch 'origin/master' 2013-07-30 17:19:41 -03:00
Robert Buckley
396b7ae639 SF ticket #53 Action Error Response not returned
In soap_ctrlpt.c, in function get_response_value:

upnp_error_code is checked to see if it is less than 400 because that
would indicate a SOAP error code.

However it should be checked to see if it is greater than 400.
(cherry picked from commit 7b1aa4c9e3)
2013-07-30 17:08:19 -03:00
Zheng Peng
a641a27cb6 SF ticket #116 UpnpRemoveVirtualDir wrong linked list operation
What if pVirtualDirList has two nodes and what we want to delete is the
first one. Patch attached.
(cherry picked from commit 907c7c2621)
2013-07-30 16:05:57 -03:00
Sebastian Brandt
97b6be674a Fix for crash in webserver.c by Sebastian Brandt
Dear libupnp-devels,
when POST'ing to the simple web server in libupnp, the application crashes.
This is caused by a missing "..." argument in webserver.c:1533.
Seems it has been there for a long time ... 1.6.9 and 1.6.18 have it.

webserver.c:1533 calls http_MakeMessage
/* Send response. */
http_MakeMessage(&headers, 1, 1,
	 "RTLSXcCc",
	 ret, "text/html", X_USER_AGENT);
The format parameter RTLSXcCc needs four arguments -
R - response code - ret,
T- content type - text/html,
L - struct SendInstruction * - NOT PRESENT
X - user agent - X_USER_AGENT

This results in a crash.

Changing to
http_MakeMessage(&headers, 1, 1,
	 "RTLSXcCc",
	 ret, "text/html", &RespInstr, X_USER_AGENT);
solves the situation.

Yours,
Sebastian Brandt
(cherry picked from commit 25c27b8af7)
2013-07-30 15:35:03 -03:00
Marcelo Roberto Jimenez
da34d1ecfe Fix for portability issue with GNU make extension 'sort'
upnp/sample/Makefile.am:67: warning: sort \
upnp/sample/Makefile.am:67:                     $(tv_ctrlpt_SOURCES: non-POSIX variable name
upnp/sample/Makefile.am:67: (probably a GNU make extension)

Reference:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13771#8
(cherry picked from commit dcbbc30f5c)
2013-07-30 15:32:13 -03:00
Thijs Schreijer
31acda9688 reverted the uuid functions export, too complicated to export them properly in the upnp.so file. 2013-04-27 09:30:29 +02:00
Thijs Schreijer
c45b279d6f additional header to be installed for *nix to export the uuid functions 2013-04-26 18:43:06 +02:00
Thijs Schreijer
0a5bf524cb added uuid.h to installed header files list, and added SCRIPTSUPPORT to the autoconf configure.ac file 2013-04-26 13:37:08 +02:00
Marcelo Roberto Jimenez
2bb79879b7 Security fix for CERT issue VU#922681
This patch addresses three possible buffer overflows in function
unique_service_name(). The three issues have the folowing CVE
numbers:

CVE-2012-5958 Issue #2: Stack buffer overflow of Tempbuf
CVE-2012-5959 Issue #4: Stack buffer overflow of Event->UDN
CVE-2012-5960 Issue #8: Stack buffer overflow of Event->UDN

Notice that the following issues have already been dealt by previous
work:

CVE-2012-5961 Issue #1: Stack buffer overflow of Evt->UDN
CVE-2012-5962 Issue #3: Stack buffer overflow of Evt->DeviceType
CVE-2012-5963 Issue #5: Stack buffer overflow of Event->UDN
CVE-2012-5964 Issue #6: Stack buffer overflow of Event->DeviceType
CVE-2012-5965 Issue #7: Stack buffer overflow of Event->DeviceType
(cherry picked from commit f015a132e8)
2012-12-06 15:46:09 -02:00
Thijs Schreijer
3f37b55ebc exported the UUID function to enable reuse in client applications 2012-10-21 21:26:11 +02:00
Thijs Schreijer
2a0d73aeac Merge branch 'master' of git://github.com/mrjimenez/pupnp 2012-10-14 08:33:19 +02:00
Thijs Schreijer
d00e494481 Updated parameter to UpnpAcceptSubscriptionExt to a 'const' declaration, this aligns with UpnpAcceptSubscription 2012-07-11 23:18:23 +02:00
Marcelo Roberto Jimenez
9f17244f95 Remove an unused variable
(cherry picked from commit 40e90e89fc)
2012-06-20 22:06:38 -03:00
Marcelo Roberto Jimenez
40d5a1dea3 Remove an unused variable ifndef INET_IPV6
(cherry picked from commit 40ddff1096)
2012-06-20 22:06:38 -03:00
Marcelo Roberto Jimenez
fa9aef8eb6 Remove a pointless way to test a return value
(cherry picked from commit 692813d03e)
2012-06-20 22:06:38 -03:00
Yoichi NAKAYAMA
f67de332a1 Fix memory leak and access violation in UpnpSendAction(Ex)Async.
Free buffers after malloc or ixmlPrintNode failure.
Free Param->Header before destructing Param.
(cherry picked from commit d9e90499b7)
2012-06-20 21:10:23 -03:00
Anoop Mohan
4d88a2a4ea Fixes a bug in non blocking connect call
This patch fixes a bug in non blocking connect call where the sock
option length for SO_ERROR was passed as 0 instead of sizeof(int).
(cherry picked from commit 6db2271ac3)
2012-05-25 13:40:32 -03:00
Yoichi NAKAYAMA
dc29948893 Disable SetGenaCallback call if device is disabled.
If device is disabled, SetGenaCallback definition is disabled,
but its call remains. A link error will occur in Win32.
(cherry picked from commit 4d21d45da7)
2012-04-24 14:25:27 -03:00
Yoichi NAKAYAMA
c27a089d6f Fix problems detected as dead assignment warning by clang scan-build.
Wrong assignment by shutdown result hides the real error code
of NewRequestHandler() in ssdp_device.c.
Fix return code description of NewRequestHandler().
Handle return code from ithread_create in sample applications.
Remove unused assignments.

(forward ported from commit 39dfad2cba)
2012-04-24 14:21:47 -03:00
Marcelo Roberto Jimenez
b1646eb0a3 Add errno.h inclusion in unixutil.h only in WIN32
(cherry picked from commit c661180d15)
2012-04-11 17:46:34 -03:00
Thijs Schreijer
615f5d18ac Fixed redefinition warnings for EAFNOSUPPORT and EADDRINUSE, Google turned up that they are newly defined in VS2010
unixutil.h, line 41
upnputil.h, line 125

Had a look here; http://bugs.ruby-lang.org/issues/3092 and added the mentioned fixes as found here; http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/win32.h?r1=27222&r2=27236&pathrev=27258&diff_format=h and here http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/win32.h?r1=27236&r2=27258&pathrev=27258&diff_format=h
(cherry picked from commit 89fe655aee)
2012-04-11 17:46:34 -03:00
Yoichi NAKAYAMA
4e25119237 Avoid access violation after parser_parse_chunky_headers call.
In parser_parse_chunky_headers, parser->msg.msg.buf can be changed
by membuffer_delete call. Therefore if we save the pointer to
parser->msg.entity.buf before calling membuffer_delete, it will
induce access to released memory.
(cherry picked from commit d72bb5cff5)
2012-04-11 14:40:57 -03:00
Gustavo Zacarias
88b94b5116 ssdp_device: exclude IPv6 stuff when there's no IPv6
Add an additional INET_IPV6 exclusion around IPV6_MULTICAST_HOPS since
the definition isn't guaranteed to exist when the toolchain lacks IPv6
support.

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
(cherry picked from commit 1c21e6e54f)
2012-04-11 11:57:19 -03:00
Yoichi NAKAYAMA
77559473c1 Remove possibility of access violation.
1. Test Instr before dereference it in http_RecvPostMessage.
(Though it never becomes NULL because NULL is not passed to
the static method)
2. Avoid strdup(NULL) in ixmlElement_setAttributeNS.
Those are detected by llvm scan-build.
(cherry picked from commit a383cbb8e2)
2012-04-10 11:01:04 -03:00
Yoichi NAKAYAMA
79d4b583fe SF Bug Tracker id 3507819 - Use of thread-unsafe gmtime() in httpreadwrite.c
Define http_gmtime_r and web_server_asctime_r and use it.
Those prefix are added since pthread for Win32 already
has macro gmtime_r and asctime_r.

(forward port of commit 34a77cc095)
2012-04-10 11:00:09 -03:00
Yoichi NAKAYAMA
85fd18ad64 Fix type of local variable stopSock in RunMiniServer()
The variable is declared as SOCKET, but it is used to
store return value of int receive_from_stopSock(...).
The type was changed in the commit
4b47e6a51d by mistake.
(cherry picked from commit e10bc2ec0c)
2012-04-10 10:38:14 -03:00
Fabrice Fontaine
320e33ac5a Compilation optimisation
Do not compile the code related to the webserver in http_SendMessage
when --disable-webserver is set
(cherry picked from commit 777c936f4c)
2012-04-03 13:46:09 -03:00
Fabrice Fontaine
b58ee1930c Add --enable-unspecified_server
Add --enable-unspecified_server configure option to set to "Unspecified"
the OS name, OS version, product name and product version normally
contained in the SERVER header as this could be used by an attacker.

(forward port of commit 49af91fe48)
2012-03-30 17:32:31 -03:00
Fabrice Fontaine
57af94b287 Removing implicit casts in miniserver.c
Removing implicit integer or enum casts in miniserver.c.
(cherry picked from commit df27ba505f)
2012-03-30 17:24:07 -03:00
Fabrice Fontaine
0f4458c999 SF Bug Tracker id 3512833 - Miniserver is wrongly disabled
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-03-29 07:36:34 PDT

Miniserver is disabled if ECXLUDE_GENA, EXCLUDE_SOAP and
EXCLUDE_WEBSERVER are set.
However, SSDP needs the Miniserver to answer to M-SEARCH requests.
So, MiniServer should not be disabled if EXCLUDE_SSDP is not also set.
(cherry picked from commit 9a33782ab5)
2012-03-30 17:24:07 -03:00
Yoichi NAKAYAMA
f9ae88182e SF Bug Tracker id 3510693 - build fail with --disable-device
Use INCLUDE_DEVICE_APIS instead of UPNP_HAVE_DEVICE as in other sources.
Don't use soap_device_callback if INCLUDE_DEVICE_APIS is not set,
otherwise link error occur on Windows.
(cherry picked from commit e0e81e6cd2)
2012-03-26 13:51:25 -03:00
Fabrice Fontaine
cc99e6e865 SF Bug Tracker id 3511149 - --disable-ssdp has no effect
Submitted: Yoichi NAKAYAMA ( yoichi ) - 2012-03-25 18:14:34 PDT

There are typos in upnp/src/inc/config.h "EXCLUDE_SSSDP" (shold be
EXCLUDE_SSDP), therefore EXCLUDE_SSDP is always 0, and --disable-ssdp
has no effect.
(cherry picked from commit 02afbb09c9)
2012-03-26 11:32:10 -03:00