Commit Graph

494 Commits

Author SHA1 Message Date
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
Marcelo Roberto Jimenez
5969530dcf 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’
2012-03-15 11:48:03 -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
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
ecaf15417a Fix for compiler warning
src/genlib/net/http/httpreadwrite.c: In function
‘http_OpenHttpConnection’:
src/genlib/net/http/httpreadwrite.c:1072:69: warning: unused parameter
‘timeout’
2012-03-13 15:20:28 -03:00
Marcelo Roberto Jimenez
4cd4b1789f 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

(forward port of commit f1c4ffefda)
2012-03-13 15:00:57 -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
Yoichi NAKAYAMA
12b88a9fbf Suppress compiler warning in CreateClientRequestPacketUlaGua.
It is a static function and is called with AF_INET6,
so there is no real problem.
(cherry picked from commit 8e39b2af85)
2012-03-11 20:59:29 -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
Yoichi NAKAYAMA
7308f42a7a 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.
(cherry picked from commit 1b38cc963a)
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
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
Yoichi NAKAYAMA
da1dec9ee5 Detect overflow in addrToString called from configure_urlbase.
Pass output buffer size to addrToString and detect overflow.
Handle addrToString error in configure_urlbase.
(cherry picked from commit 56b44fee91)
2012-03-11 12:09:46 -03:00
Yoichi NAKAYAMA
6ba4181fe6 Detect overflow in CreateClientRequestPacket(UlaGua).
Pass output buffer size to CreateClientRequestPacket(UlaGua)
from SearchByTarget and detect overflow.
Handle SearchByTarget error in UpnpSearchAsync.
(cherry picked from commit ff635f92c0)
2012-03-11 12:09:46 -03:00
Yoichi NAKAYAMA
1ed33f3c5b Clarify the last argument of GetDescDocumentAndURL has size LINE_SIZE.
(cherry picked from commit 19a23dafba)
2012-03-11 12:09:46 -03:00
Yoichi NAKAYAMA
4e20af9ee9 For inet_ntop, use buffer with size INET6_ADDRSTRLEN or INET_ADDRSTRLEN.
(cherry picked from commit bd7f83feb5)
2012-03-11 12:09:46 -03:00
Yoichi NAKAYAMA
37b0afe1dc Treat large argument as error in UpnpAddVirtualDir.
(cherry picked from commit e4678168fa)
2012-03-11 12:09:46 -03:00
Yoichi NAKAYAMA
17e1f6aa09 Do not clear buffer before snprintf.
It had no effect since snprintf can overwrite whole buffer.
(cherry picked from commit a0dc3482dc)
2012-03-11 12:09:45 -03:00
Yoichi NAKAYAMA
659182ef9b Add assertion and narrow variable scope in resolve_rel_url().
I've confirmed enough buffer is allocated for output.
(cherry picked from commit 87d1d3c3ec)
2012-03-11 12:09:45 -03:00
Yoichi NAKAYAMA
6ea4cc41ef Handle allocation error in strndup to avoid access violation.
Return NULL before calling strncpy.
Platforms with HAVE_STRNDUP are not affected.
(cherry picked from commit 194397b6d6)
2012-03-11 12:09:45 -03:00
Yoichi NAKAYAMA
2b3f5bbcee 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.
(cherry picked from commit b78eaf4e43)
2012-03-11 12:09:45 -03:00
Yoichi NAKAYAMA
97e1f19323 fix missing assignment in commit e722d8c375
(cherry picked from commit 18bf3b1c9c)
2012-03-11 12:09:45 -03:00
Fabrice Fontaine
77d42c2db1 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.

(forward port of commit bb140000c0)
2012-03-11 12:08:47 -03:00
Fabrice Fontaine
a12d5a6f7d Optimisation of --disable-webserver
Do not compile webserver.c if --disable-webserver is used.
(cherry picked from commit 7aef73d7eb)
2012-03-11 12:05:29 -03:00
Fabrice Fontaine
783ebbc0ca Optimisation of --disable-webserver
Do not compile miniserver.c if --disable-webserver is used.
(cherry picked from commit 72eecacf56)
2012-03-09 12:15:03 -03:00
Fabrice Fontaine
f27461c871 Adding configure options
Adding --disable-ssdp, --disable-soap, --disable-gena options to
configure script.
(cherry picked from commit 601332f88f)
2012-03-09 12:15:03 -03:00
Fabrice Fontaine
10ad771410 Bug fix of last commit
_snprintf was wrongly defined in ssdp_server.c
(cherry picked from commit e95b4cc53a)
2012-03-09 11:21:40 -03:00
Fabrice Fontaine
d19c0757dc SF Bug Tracker id 3499781 - msvc doesn't have snprintf
Submitted: Yoichi NAKAYAMA ( yoichi ) - 2012-03-08 10:18:39 PST

97a17ff5ad commit breaks build on
windows/msvc since there is no snprintf.

Note:
* Some existing sources use _snprintf when WIN32 is defined, but its
behavior is a bit different from C99 snprintf.
* snprintf does terminate the buffer, so the commit (use buffer size
minus 1 as argument) changes the behavior at the boundary.
* Truncation might be better than crash in some cases. But it may
result in not good.

(forward port of commit e722d8c375)
2012-03-09 11:21:40 -03:00
Marcelo Roberto Jimenez
4bd3b6b969 SF Bug Tracker id 3499878 - UpnpUnSubscribeAsync(): ‘retVal’ may be used uninitialized
Submitted: Marcelo Roberto Jimenez ( mroberto ) - 2012-03-08 12:38:57 PST

src/api/upnpapi.c: In function ‘UpnpUnSubscribeAsync’:
src/api/upnpapi.c:2060:6: warning: ‘retVal’ may be used uninitialized in this function
(cherry picked from commit 29ee36b1ca)
2012-03-08 17:42:36 -03:00
Fabrice Fontaine
10805cb8cc Memory leaks correction in upnpapi.c
Fix memory leaks in UpnpUnSubscribe, SendActionExAsync and
RenewSubscription.
(cherry picked from commit 3ab8d536a0)
2012-03-08 13:08:52 -03:00
Fabrice Fontaine
0edaf3361d Remove most of strcpy, sprintf and strcat
Replace strcpy, sprintf and strcat by strncpy, snprintf and strncat to
avoid buffer overflows.

(forward port of commit 97a17ff5ad)
2012-03-08 13:08:52 -03:00
Fabrice Fontaine
beae2ea332 Check for NULL pointer in TemplateSource.h
calloc can return NULL so check for NULL pointer in CLASS##_new and
CLASS##_dup.
2012-03-08 17:55:19 +01:00
Fabrice Fontaine
666bc7392b Replace strcpy with strncpy in get_hoststr
Replace strcpy with strncpy to avoid buffer overflow.
2012-03-08 17:23:46 +01:00
Fabrice Fontaine
eb16f52b1a Memory leak fix in handle_query_variable
variable was never freed.
2012-03-08 14:30:33 +01:00
Yoichi NAKAYAMA
4fd84cbee1 SF Bug Tracker id 3497714 - Buffer overflows
Fix compile error on WIN32.

Local variables must be declared first.
Remove outdated comment.

(forward port of commit 4c3532585d)
2012-03-07 16:23:17 -03:00
Fabrice Fontaine
0b2a4e580e Remove SIZEOF_MISTACH error in notify_send_and_recv
Replace sizeof(CRLF) by strlen(CRLF) as CRLF is a const char*.
(cherry picked from commit cec9d55c4c)
2012-03-07 16:16:51 -03:00
Fabrice Fontaine
81f10bcffb SF Bug Tracker id 3498439 - Memory leak in removeServiceTable
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-03-07 02:35:46 PST

UDN is not freed.
(cherry picked from commit 0469388b73)
2012-03-07 16:03:13 -03:00
Fabrice Fontaine
d4c20442fc Removing two unused variables in ssdp_server.c
Removing first TempPtr allocation in unique_service_name as well as one
of the dbgStr allocation in AdvertizeAndReply as those values were not
used.
(cherry picked from commit 7ef089b09a)
2012-03-06 20:31:49 -03:00