Commit Graph

360 Commits

Author SHA1 Message Date
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
8eaaf0f171 Fix condition for allocation failure in get_content_type().
At the end of get_content_type() in webserver.c, it should check
return value of ixmlCloneDOMString().

(Forward ported from commit 708ea30806)
2012-04-24 14:24:43 -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
Yoichi NAKAYAMA
76e8812acc Avoid dereference of null pointer in ixmlNode_setNodeProperties.
The problem can occur if one of the arguments is NULL.
Test argument and fix assertion.
(cherry picked from commit 3d7c1dbd59)
2012-04-24 14:16:17 -03:00
Yoichi NAKAYAMA
3b2cfdc45d Create intermediate directory per project on vc9.
Sample applications share sample_util.c and collisions of
object file can occur in parallel build. Modify project files to
split intermediate directories against it.
Apply similar changes also to library projects, like vc10 projects.
(cherry picked from commit e52e7e0bd3)
2012-04-17 10:56:27 -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
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
Marcelo Roberto Jimenez
99ef28b091 Homekeeping to match the stable branch release. 2012-04-03 09:56:03 -03:00
Fabrice Fontaine
3d46251c4e Memory leak fix in threadutil
Put thread in a detached state when calling pthread_create otherwise in
some circumstances, thread can end before the call to pthread_detach.
(cherry picked from commit dc4eda529f)
2012-04-03 09:11:47 -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
Fabrice Fontaine
f99dba3967 Remove implicit casts
Cast parameters of htonl in uint32_t in IN6_IS_ADDR_GLOBAL and
IN6_IS_ADDR_ULA definitions.
Remove comparison with 0 in while statement of vfmatch,
http_SendMessage and http_MakeMessage.
(cherry picked from commit 804088d859)
2012-03-26 11:32:10 -03:00
Yoichi NAKAYAMA
664176c8d6 SF Bug Tracker id 3510693 - build fail with --disable-device
GetDeviceHandleInfo just fail without using undefined member DeviceAf
if UPNP_HAVE_DEVICE is not defined.
Move ContentTypeHeader definition to soap_common.c, since it is
also used in soap_ctrlpt.c.
(cherry picked from commit 679ebeec48)
2012-03-26 11:32:09 -03:00
Fabrice Fontaine
ad617d7c9c SF Bug Tracker id 3510595 - UpnpDownloadXmlDoc : can't get the file
Submitted: Marco Virgulti ( mvirg83 ) - 2012-03-23 10:08:08 PDT

There is a problem, perhaps, during downloading a document by
UpnpDownloadXmlDoc. During debugging i've found that in an not exported
api (unfortunately i forgot the code line...) where it is setted a
local variable "int timeout" to -1 then passed directly to another
function for sending data through tcp socket. I patched this setting it
to 0 (there is an IF section that exits if timeout < 0). It is normal
behavior or it is a bug?
2012-03-24 22:08:11 +01:00
Marcelo Roberto Jimenez
5cd98b1330 Homekeeping to match the stable branch release. 2012-03-21 20:13:51 -03:00
Fabrice Fontaine
bc1e797e95 Replace sprintf by snprintf in http_WriteHttpPost
Replace sprintf by snprintf in http_WriteHttpPost to avoid buffer
overflow.

(Forwar port of commit a04c36f47e)
2012-03-19 11:49:32 -03:00
Fabrice Fontaine
1aecc6c44f Add infoSize parameter to get_sdk_info
Add infoSize parameter to get_sdk_info function to replace sprintf call
by a snprintf call.
(cherry picked from commit e13ffe3bf8)
2012-03-19 11:48:03 -03:00
Fabrice Fontaine
c42216dad7 Check return code in ixml
Check return code of ixmlDocument_CreateElementEx in
ixmlDocument_CreateElement.
Check return code of ixmlNode_setNodeName and ixmlNode_setNodeValue in
ixmlNode_cloneCDATASect and ixmlNode_cloneTextNode.
(cherry picked from commit d3d17da6e5)
2012-03-19 11:48:03 -03:00
Fabrice Fontaine
06f87abc2c Add more explicit casts and remove dead code
Comment unused SERVER from DeviceShutdown.
Comment unused max from parse_hostport.
Comment unused nodeptr from ixmlNode_cloneDoc.
Comment unused newNode from Parser_hasDefaultNamespace.
Comment unused Parser_parseReference function
Check return code of shutdown and display an error if needed.

(forward port of commit cb07623dde)
2012-03-16 12:00:21 -03:00
Fabrice Fontaine
21c881cbf9 Fix previous commit
Replace HAVE_UPNP_OPTSSDP by UPNP_HAVE_OPTSSDP in upnpapi.c.
(cherry picked from commit a3d038c885)
2012-03-15 11:49:01 -03:00
Fabrice Fontaine
b53d552d3f Add --disable-optssdp option
Modify configure.ac to add --disable-optssdp option. This option will
remove OPT, 01-NLS and X_USER_AGENT headers from SSDP messages as those
headers are optional. If --disable-gena and disable-optssdp are both
used, uuid part will not be compiled anymore.
(cherry picked from commit 731512b0e5)
2012-03-15 11:49:00 -03:00
Fabrice Fontaine
fec6069a21 Bug fix in ixmlNode_allowChildren
Commit d48d73720b added a bug in
ixmlNode_allowChildren, this function was returning FALSE instead of
TRUE when newChild->nodeName was eELEMENT_NODE.
(cherry picked from commit 76eb3f869b)
2012-03-15 11:49:00 -03:00
Fabrice Fontaine
b9944242cf Improve upnp/genlib/net
Change ret_code from int to parse_status_t in match.
Set back return code of ReadResponseLineAndHeaders from parse_status_t
to int as this function can return UPNP_E_BAD_HTTPMSG. As a result, do
not cast the result of this function into parse_status_t in
http_OpenHttpGetProxy and http_OpenHttpGetEx.
Use switch with PARSE_OK in parsetools.c.
Add missing explicit casts of integer constants in uri.c and
httpreadwrite.c.
Use switch, int and sa_family_t with AF_INET in uri.c.
Print an error in http_Download if realloc failed.

(forward port of commit b116d10f37)
2012-03-15 11:32:02 -03:00
Fabrice Fontaine
9a1ca957a7 Use switch instead of if with enums in upnpapi.c
Replace if statements with switch when using HND_DEVICE and HND_CLIENT
enum constants.
Correct also UpnpUnRegisterRootDeviceLowPower and UpnpUnRegisterClient
as those functions were wrongly awaiting an UPNP_E_INVALID_HANDLE
instead of HND_INVALID from GetHandleInfo.
(cherry picked from commit 1a083479a9)
2012-03-14 20:27:49 -03:00
Fabrice Fontaine
975c5257a3 Improve ssdp part
Do not compile CreateClientRequestPacketUlaGua if IPv6 is disable.
Cast DestAddr->sa_family from sa_family_t into int when calling
CreateServicePacket as this function has been set back to accept int in
a692e591de.
Use switch instead of if with AF_INET and AF_INET6.
Add missing casts from AF_INET and AF_INET6 into sa_family_t when using
them to set sin_family and sin6_family.
Add missing explicit casts into size_t or lu when using integer
constants with strlen or unsigned long indexes.
Set SSDP_PAUSE to be unsigned as it is used with usleep.
(cherry picked from commit 850e6b4849)
2012-03-14 20:27:49 -03:00
Fabrice Fontaine
a820f2ecce Use switch insted of if with enums in ixml
Replace if statements with switch when using enums in ixml.
Remove uneeded initialization in ixmlAttr_init, Parser_init and
ixmlNode_init which was added by wrongly added in commit
06660b6383.
(cherry picked from commit d48d73720b)
2012-03-14 20:27:49 -03:00
Fabrice Fontaine
f65b68a9bc Use switch insted of if with enums in threadutil
Replace if statements with switch when using enums in threadutil.
(cherry picked from commit b7f83bb7c6)
2012-03-14 20:27:49 -03:00
Fabrice Fontaine
6bd5086a88 Fix missing break in http_RecvMessage
There was a missing break in PARSE_INCOMPLETE_ENTITY due to commit
2eb3e069ba.
(cherry picked from commit 05fb3f8026)
2012-03-14 20:27:49 -03:00
Yoichi NAKAYAMA
cca16cbead Fix parse failure observed with tvdevice sample.
Commit c40d2bc0c9 has a problem
at removing the parentheses in parser_parse_responseline.
Difference of pointers was used with intention, don't cast
them separately.
(cherry picked from commit 7178f300bb)
2012-03-14 20:27:49 -03:00
Yoichi NAKAYAMA
168444761d Fix compile error on Windows.
Include UpnpStdInt.h for ssize_t.
Define sa_family_t in UpnpInet.h.
(cherry picked from commit f7a801c3ae)
2012-03-14 20:27:48 -03:00
Yoichi NAKAYAMA
0aa8228dac Avoid ambiguous change of SsdpEvent in unique_service_name.
Handle overflow before changing SsdpEvent.
Because the behavior of "snprintf" is platform dependent in such case.
(cherry picked from commit f299d6597a)
2012-03-14 11:20:13 -03:00
Yoichi NAKAYAMA
4b8982970e SF Bug Tracker id 3502958 - The commit 5944960e prevents a pupnp client (amule) from receiving replies from an IGD device.
Previous change broke the feature. The error of unique_service_name
in ssdp_request_type should be ignored.
This reverts commit 5944960e17.
(cherry picked from commit 35819a7a44)
2012-03-14 11:20:13 -03:00
Marcelo Roberto Jimenez
461a478c25 Address family is an int
Reference: "man 2 socket".
(cherry picked from commit a692e591de)
2012-03-13 14:33:20 -03:00
Fabrice Fontaine
46da1738b9 Remove more implicit casts in upnp part
Remove more "implicit integer or enum conversions" errors as well as
dead code.

(forward port of commit c40d2bc0c9)
2012-03-11 21:38:56 -03:00
Fabrice Fontaine
d56a68d771 Remove more implicit casts in upnp part
Remove more "implicit integer or enum conversions" as well as memset
before snprintf.

(forward port of commit 2eb3e069ba)
2012-03-11 20:58:28 -03:00
Yoichi NAKAYAMA
e2de269593 Avoid out of range access in CheckOtherHTTPHeaders.
There was a problem in HDR_ACCEPT_LANGUAGE case.
It may read from TmpBuf larger amount than allocated,
since condition was always true.
Terminate RespInstr->AcceptLanguageHeader correctly.
Skip allocation if there is already sufficient buffer.
(cherry picked from commit db532afb9b)
2012-03-11 12:17:22 -03:00
Fabrice Fontaine
f020c4f5fb Remove some of the implicit cast in upnp part
Remove some of the "implicit integer or enum conversions" as well as
some access to NULL reference in upnp part.

(forward port of commit c67187ac94)
2012-03-11 12:16:15 -03:00
Fabrice Fontaine
24f12e3ce0 Remove lock in ThreadPoolInit
If ThreadPoolInit returned EAGAIN, tp->lock was not freed.
(cherry picked from commit d45f3c28cf)
2012-03-11 12:09:47 -03:00
Fabrice Fontaine
404867107d Improve ixml
Remove "implicit integer conversions" and
"dereference NULL return value" errors in ixml part.
(cherry picked from commit 06660b6383)
2012-03-11 12:09:47 -03:00
Yoichi NAKAYAMA
c8fdafc79c Exclude IPv6 stuff in SearchByTarget when UPNP_ENABLE_IPV6 is not defined.
(cherry picked from commit 41412c16ef)
2012-03-11 12:09:47 -03:00
Yoichi NAKAYAMA
8871805c77 Use strncpy with the standard way in readFromSSDPSocket.
(cherry picked from commit 04e5767ea0)
2012-03-11 12:09:47 -03:00
Yoichi NAKAYAMA
c9024bbb40 Respect unique_service_name error in ssdp_request_type.
Respect unique_service_name error in ssdp_request_type
so as not to touch non-terminated buffer under Evt.
(cherry picked from commit 5944960e17)
2012-03-11 12:09:46 -03:00
Yoichi NAKAYAMA
9223094468 Handle overflow in http_SendMessage.
(cherry picked from commit d952ebfb44)
2012-03-11 12:09:46 -03:00