Commit Graph

375 Commits

Author SHA1 Message Date
Yoichi NAKAYAMA
a383cbb8e2 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.
2012-04-06 23:21:18 +09:00
Yoichi NAKAYAMA
34a77cc095 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.
2012-04-06 03:13:43 +09:00
Yoichi NAKAYAMA
e10bc2ec0c 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.
2012-04-06 00:07:56 +09:00
Fabrice Fontaine
777c936f4c Compilation optimisation
Do not compile the code related to the webserver in http_SendMessage
when --disable-webserver is set
2012-04-03 16:11:31 +02:00
Fabrice Fontaine
49af91fe48 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.
2012-03-30 21:57:51 +02:00
Fabrice Fontaine
df27ba505f Removing implicit casts in miniserver.c
Removing implicit integer or enum casts in miniserver.c.
2012-03-29 17:10:07 +02:00
Fabrice Fontaine
9a33782ab5 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.
2012-03-29 16:40:40 +02:00
Yoichi NAKAYAMA
e0e81e6cd2 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.
2012-03-27 00:59:50 +09:00
Fabrice Fontaine
02afbb09c9 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.
2012-03-26 14:07:52 +02:00
Fabrice Fontaine
804088d859 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.
2012-03-24 22:20:18 +01:00
Yoichi NAKAYAMA
679ebeec48 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.
2012-03-24 13:11:23 +09:00
Fabrice Fontaine
a04c36f47e Replace sprintf by snprintf in http_WriteHttpPost
Replace sprintf by snprintf in http_WriteHttpPost to avoid buffer
overflow.
2012-03-18 16:14:41 +01:00
Fabrice Fontaine
e13ffe3bf8 Add infoSize parameter to get_sdk_info
Add infoSize parameter to get_sdk_info function to replace sprintf call
by a snprintf call.
2012-03-18 15:23:59 +01:00
Marcelo Roberto Jimenez
e0444b26e6 Don't use // as comments, it breaks some C compilers
Also, really remove the dead code.
2012-03-16 11:51:10 -03:00
Fabrice Fontaine
cb07623dde 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.
2012-03-16 11:30:42 +01:00
Marcelo Roberto Jimenez
c9f3e26f24 Fix for compiler warning messages
src/genlib/net/http/httpreadwrite.c: In function ‘http_Download’:
src/genlib/net/http/httpreadwrite.c:790:5: warning: format ‘%d’ expects
type ‘int’, but argument 6 has type ‘size_t’
src/genlib/net/http/httpreadwrite.c:790:5: warning: format ‘%d’ expects
type ‘int’, but argument 7 has type ‘size_t’
(cherry picked from commit 5969530dcf)
2012-03-15 11:50:48 -03:00
Fabrice Fontaine
a3d038c885 Fix previous commit
Replace HAVE_UPNP_OPTSSDP by UPNP_HAVE_OPTSSDP in upnpapi.c.
2012-03-15 15:06:51 +01:00
Fabrice Fontaine
731512b0e5 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.
2012-03-15 14:13:27 +01:00
Fabrice Fontaine
b116d10f37 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.
2012-03-15 09:31:44 +01:00
Fabrice Fontaine
1a083479a9 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.
2012-03-14 22:22:43 +01:00
Fabrice Fontaine
850e6b4849 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.
2012-03-14 21:30:55 +01:00
Fabrice Fontaine
05fb3f8026 Fix missing break in http_RecvMessage
There was a missing break in PARSE_INCOMPLETE_ENTITY due to commit
2eb3e069ba.
2012-03-14 18:43:14 +01:00
Yoichi NAKAYAMA
7178f300bb 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.
2012-03-15 01:02:48 +09:00
Yoichi NAKAYAMA
f7a801c3ae Fix compile error on Windows.
Include UpnpStdInt.h for ssize_t.
Define sa_family_t in UpnpInet.h.
2012-03-14 23:40:32 +09:00
Yoichi NAKAYAMA
f299d6597a 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.
2012-03-14 23:06:46 +09:00
Yoichi NAKAYAMA
35819a7a44 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.
2012-03-14 23:04:51 +09:00
Marcelo Roberto Jimenez
f1c4ffefda Fix for compiler warning
src/genlib/net/sock.c: In function ‘sock_read_write’:
src/genlib/net/sock.c:172:4: warning: conversion to ‘long int’ from
‘size_t’ may change the sign of the result
2012-03-13 14:57:22 -03:00
Marcelo Roberto Jimenez
a692e591de Address family is an int
Reference: "man 2 socket".
2012-03-13 14:32:19 -03:00
Fabrice Fontaine
c40d2bc0c9 Remove more implicit casts in upnp part
Remove more "implicit integer or enum conversions" errors as well as
dead code.
2012-03-11 22:45:10 +01:00
Yoichi NAKAYAMA
8e39b2af85 Suppress compiler warning in CreateClientRequestPacketUlaGua.
It is a static function and is called with AF_INET6,
so there is no real problem.
2012-03-11 21:35:03 +09:00
Fabrice Fontaine
2eb3e069ba Remove more implicit casts in upnp part
Remove more "implicit integer or enum conversions" as well as memset
before snprintf.
2012-03-10 22:52:57 +01:00
Yoichi NAKAYAMA
db532afb9b 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.
2012-03-11 13:21:40 +09:00
Yoichi NAKAYAMA
1b38cc963a Suppress compiler warning in CreateClientRequestPacket.
It is a static function and is called with AF_INET or AF_INET6,
so there is no real problem.
2012-03-11 12:41:32 +09:00
Fabrice Fontaine
c67187ac94 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.
2012-03-10 20:44:49 +01:00
Yoichi NAKAYAMA
41412c16ef Exclude IPv6 stuff in SearchByTarget when UPNP_ENABLE_IPV6 is not defined. 2012-03-11 04:00:09 +09:00
Yoichi NAKAYAMA
04e5767ea0 Use strncpy with the standard way in readFromSSDPSocket. 2012-03-11 03:54:41 +09:00
Yoichi NAKAYAMA
5944960e17 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.
2012-03-11 03:52:37 +09:00
Yoichi NAKAYAMA
d952ebfb44 Handle overflow in http_SendMessage. 2012-03-11 03:33:14 +09:00
Yoichi NAKAYAMA
56b44fee91 Detect overflow in addrToString called from configure_urlbase.
Pass output buffer size to addrToString and detect overflow.
Handle addrToString error in configure_urlbase.
2012-03-11 03:25:41 +09:00
Yoichi NAKAYAMA
ff635f92c0 Detect overflow in CreateClientRequestPacket(UlaGua).
Pass output buffer size to CreateClientRequestPacket(UlaGua)
from SearchByTarget and detect overflow.
Handle SearchByTarget error in UpnpSearchAsync.
2012-03-11 02:47:58 +09:00
Yoichi NAKAYAMA
19a23dafba Clarify the last argument of GetDescDocumentAndURL has size LINE_SIZE. 2012-03-11 02:15:16 +09:00
Yoichi NAKAYAMA
bd7f83feb5 For inet_ntop, use buffer with size INET6_ADDRSTRLEN or INET_ADDRSTRLEN. 2012-03-11 01:57:34 +09:00
Yoichi NAKAYAMA
e4678168fa Treat large argument as error in UpnpAddVirtualDir. 2012-03-11 01:40:48 +09:00
Yoichi NAKAYAMA
a0dc3482dc Do not clear buffer before snprintf.
It had no effect since snprintf can overwrite whole buffer.
2012-03-11 01:16:12 +09:00
Yoichi NAKAYAMA
87d1d3c3ec Add assertion and narrow variable scope in resolve_rel_url().
I've confirmed enough buffer is allocated for output.
2012-03-11 00:42:49 +09:00
Yoichi NAKAYAMA
194397b6d6 Handle allocation error in strndup to avoid access violation.
Return NULL before calling strncpy.
Platforms with HAVE_STRNDUP are not affected.
2012-03-10 23:15:37 +09:00
Yoichi NAKAYAMA
b78eaf4e43 Fix buffer size for strncpy in UpnpAddVirtualDir()
Since 1st argument precedes the beginning of the buffer,
it is necessary to reduce the value of 3rd argument.
2012-03-10 22:29:44 +09:00
Yoichi NAKAYAMA
18bf3b1c9c fix missing assignment in commit e722d8c375 2012-03-10 12:50:11 +09:00
Fabrice Fontaine
bb140000c0 More compilaton optimisation
Do not compile most of service_table.c and client_table.c if
--disable-gena is used.
Do not compile urlconfig.c if --disable-webserver is used.
Adding new UPNP_HAVE_xxx variables in upnpconfig.h and upnpconfig.h.in.
2012-03-10 00:33:17 +01:00
Fabrice Fontaine
7aef73d7eb Optimisation of --disable-webserver
Do not compile webserver.c if --disable-webserver is used.
2012-03-09 23:28:18 +01:00