Commit Graph

693 Commits

Author SHA1 Message Date
Marcelo Roberto Jimenez
03ea4e85ab Merge remote branch 'origin/master' 2012-03-09 11:25:23 -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
Raymond Wen
0ca7637033 fix bug: the project can't compile on windows with vs 2005
- define UPNP_USE_MSVCPP when necessary
- set release build's output directory to be consistent with debug build
- add missing ClientSubscription.c to libupnp project
- reference correct source files in sample project
2012-03-09 11:21:39 -03:00
Marcelo Roberto Jimenez
0097180ce4 Merge pull request #1 from rxwen/master
fix bug: upnp can't compile on windows vs 2005
2012-03-08 13:01:16 -08: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
Marcelo Roberto Jimenez
027ce49600 SF Bug Tracker id 3175217 - Crash bug in Parser_addNamespace()
Submitted: Terry Farnham ( tfarnham ) - 2011-02-07 09:25:25 PST

Details: The strcmp(pNode->prefix,pCur->prefix) crashes on pCur->prefix
being NULL. This occurs on invalidly formatted xml where a node uses an
undefined namespace. I would expect to receive IXML_FAILED in this
situation.
(cherry picked from commit 2fb791c9bb)
2012-03-08 13:52:04 -03:00
Marcelo Roberto Jimenez
5373ed560a White spaces and coding style
(cherry picked from commit d909297aa7)
2012-03-08 13:40:05 -03:00
Fabrice Fontaine
63cccfff08 Removing access to NULL pointers in node.c and element.c
Check that newNode is not NULL ixmlNode_cloneNodeTree and pass newAttr
as the return node in the ixmlElement_setAttributeNodeNS call of
ixmlElement_setAttributeNS.
(cherry picked from commit 9b616a08df)
2012-03-08 13:08:52 -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
bd41182cf3 SF Bug Tracker id 3496993 - Write after free in ixmlNode_insertBefore
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-03-05 04:54:40 PST

If ixmlNode_isParent(nodeptr, newChild) returns TRUE,
ixmlNode_removeChild(nodeptr, newChild, NULL) will free newChild before
the modifications of newChild->nextSibling and newChild->prevSibling.
(cherry picked from commit 4f34a12a83)
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
Raymond Wen
d0aa33efc4 fix bug: the project can't compile on windows with vs 2005
- define UPNP_USE_MSVCPP when necessary
- set release build's output directory to be consistent with debug build
- add missing ClientSubscription.c to libupnp project
- reference correct source files in sample project
2012-03-08 14:09:28 +08:00
zephyrus
d02c01fa6e SF Patches Tracker id 3498437 - a header patch: ixml.h 1.6.15
Submitted: zephyrus ( zephyrus00jp ) - 2012-03-07 02:31:14 PST

Details: a function is declared as
EXPORT_SPEC IXML_Document *ixmlDocument_createDocument();

This should read as follows in order to suppress strict prototype checking by GCC.
EXPORT_SPEC IXML_Document *ixmlDocument_createDocument(void);
(cherry picked from commit 9965f02727)
2012-03-07 17:18:15 -03:00
Marcelo Roberto Jimenez
178b28593a White spaces, coding style
(cherry picked from commit 861a538cea)
2012-03-07 16:24:25 -03:00
Marcelo Roberto Jimenez
715d4d6174 White spaces, coding style
(cherry picked from commit c12d33aca6)
2012-03-07 16:24:25 -03: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
Yoichi NAKAYAMA
5a9dbdb84e Avoid access violation in assertion.
xmlParser->pCurElement was dereferenced before null check.
Affects debug build only.
(cherry picked from commit 71ab707e81)
2012-03-07 16:16:51 -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
6f64448cae SF Bug Tracker id 3498442 - Memory leak in get_file_info
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-03-07 02:44:30 PST

info->contentType is not freed before being set to NULL.

(forward port of commit 56c26b5199)
2012-03-07 16:15:09 -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
a35724f7f8 SF Bug Tracker id 3498436 - Memory leak in Parser_processAttributeName
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-03-07 02:30:57 PST

attr is not freed if ixmlNode_setNodeProperties or
ixmlNode_setAttributeNode return an error in
Parser_processAttributeName.
(cherry picked from commit 268abf72fb)
2012-03-07 16:03:13 -03:00
Fabrice Fontaine
40e7dccf5e Fixing an error in d6db7c555d commit
Evt.Sid should not be cast into char* when calling sizeof otherwise
size will be 4.

(forward port of commit 288ef35cee)
2012-03-07 16:02:17 -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
Fabrice Fontaine
d6db7c555d SF Bug Tracker id 3497714 - Buffer overflows
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-03-06 07:36:08 PST

Call to strcpy should be replaced by call to memset and strncpy to
avoid getting buffer overflows.
2012-03-06 20:31:49 -03:00
Fabrice Fontaine
908391ddf0 SF Bug Tracker id 3497159 - Bug fix in Parser_readFileOrBuffer
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-03-05 14:20:58 PST

fileSize = ftell( xmlFilePtr ); can return a negative value, in this
case the function should exit (at the moment, the function exits only
if ftell returns 0).
(cherry picked from commit a8bcbe9491)
2012-03-06 20:06:37 -03:00
Fabrice Fontaine
75fdad1108 SF Bug Tracker id 3497140 - Bug fix in http_get_code_text
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-03-05 13:07:03 PST

Replace if( statusCode < 100 && statusCode >= 600 ) which can't be true
by if( statusCode < 100 || statusCode >= 600 ).
(cherry picked from commit 1a1570fe0f)
2012-03-06 20:06:29 -03:00
Fabrice Fontaine
d4ff4ecc86 SF Bug Tracker id 3497126 - Resource leak in http_RecvPostMessage
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-03-05 12:33:59 PST

Fp is not closed when an error is raised on membuffer_append or
sock_read.
(cherry picked from commit 30badb44c7)
2012-03-06 20:06:22 -03:00
Nick Leverton
2b9e8a9b9b Update ChangeLog and configure.ac to make it easy to forward port later. 2012-03-06 20:02:59 -03:00
Yoichi NAKAYAMA
2c7658f98a SF Bug Tracker id 3325246 - Memory Leak in XML Parser
Submitted: Terry Farnham ( tfarnham ) - 2011-06-23 09:45:54 PDT

Details: The following bit of xml results in a memory leak from the xml
parser:

const char *xmlbuffer="<?xml version=\"1.0\" encoding=\"utf-8\"?>
<root xmlns=\"urn:schemas-upnp-org:device-1-0\" xmlns:dlna=\"urn:schemas-dlna-org:device-1-0\">
<dlna:X_DLNADOC xmlns:dlna=\"urn:schemas-dlna-org:device-1-0\">DMS-1.50</dlna:X_DLNADOC></root>";

When I execute the following code:

IXML_Document *doc = ixmlParseBuffer(xmlbuffer);
ixmlDocument_free(doc);

It results in a memory leak in ixmlparser.c line 2107 where it calls
safe_strdup( newElement->namespaceURI ); It's difficult to figure out why.
(cherry picked from commit d6f1e4112e)
2012-03-05 17:01:26 -03:00
Yoichi NAKAYAMA
8ffb52e330 SF Bug Tracker id 3417134 - Crash seen in UpnpFinish
Submitted: Sunil ( sunilangadi ) - 2011-10-02 08:28:47 PDT

Details: I observed crash in the below mentioned log statement in
function upnpfinish(file: upnpapi.c).
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__, "Exiting UpnpFinish:
	UpnpSdkInit is :%d:\n", UpnpSdkInit);

In particular it was crashing in ithread_self in
UpnpDisplayFileAndLine(file upnpdebug.c) on WIN32.

Moving the call ithread_cleanup_library() below the upnp printf call
mentioned above in function upnpfinish fixed the crash but I couldn't get
to the root of the problem.

The problem was observed on WIN32.
(cherry picked from commit e5887c9036)
2012-03-05 15:07:08 -03:00
Fabrice Fontaine
4b7aa238e7 SF Bug Tracker id 3497034 - Buffer not null terminated in UpnpGetIfInfo
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-03-05 06:43:52 PST

gIF_NAME might be not null terminated.
(cherry picked from commit eeab71082f)
2012-03-05 14:38:18 -03:00
Fabrice Fontaine
d1a4925359 SF Bug Tracker id 3497033 - Buffer not null terminated in UpnpInit
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-03-05 06:42:18 PST

gIF_IPV4, gIF_IPV6 and gIF_IPV6_ULA_GUA might be not null terminated.
Moreover, gIF_IPV4 should be 16 characters (INET_ADDRSTRLEN) and not 22
and gIF_IPV6 should be 46 characters (INET6_ADDRSTRLEN) and not 65.
(cherry picked from commit f6e88d5b0a)
2012-03-05 14:38:18 -03:00
Fabrice Fontaine
7264f892e7 Bug fix of lastest commit (parse_hostport)
Missing parenthesis in memset.
(cherry picked from commit add51536fc)
2012-03-05 14:38:17 -03:00
Fabrice Fontaine
898fb30183 SF Bug Tracker id 3497027 - Buffer not null terminated in parse_hostport
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-03-05 06:28:38 PST

workbuf might be not null terminated.
(cherry picked from commit 40864da7c1)
2012-03-05 14:38:17 -03:00
Fabrice Fontaine
a0951e3753 SF Bug Tracker id 3497009 - Resource leak in http_SendMessage
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-03-05 05:51:44 PST

Fp is not closed if fseeko(Fp, Instr->RangeOffset, SEEK_CUR) does not return 0.
(cherry picked from commit 5caaf3ad07)
2012-03-05 14:38:17 -03:00
Fabrice Fontaine
b5061149a6 HInfo->ServiceTable initialization in UpnpRegisterRootDevice2 and UpnpRegisterRootDevice4
Initialize also HInfo->ServiceTable in UpnpRegisterRootDevice2 and
UpnpRegisterRootDevice4 functions
(cherry picked from commit 26c3f87eca)
2012-03-05 10:33:30 -03:00
Yoichi NAKAYAMA
7dd2d33382 Initialize ServiceTable.
(cherry picked from commit 20372ccef6)
2012-03-05 10:33:30 -03:00
Yoichi NAKAYAMA
4f84435528 Add error handling.
(cherry picked from commit 47c86542bc)
2012-03-05 10:33:30 -03:00
Fabrice Fontaine
07489c1155 SF Bug Tracker id 3496942 - Memory leak in config_description_doc
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-03-05 01:55:54 PST

element was not freed if membuffer_append_str(&url_str, "http://") does
not return 0. Moreover addNew was not used.
(cherry picked from commit da244683cf)
2012-03-05 10:33:30 -03:00
Fabrice Fontaine
1dbcdaef98 SF Bug Tracker id 3496938 - Missing structures initialisation in some functions
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-03-05 01:31:16 PST

Memsetting to 0 some of the structures: finfo in process_request,
job in readFromSSDPSocket, request in http_OpenHttpGetEx, job in
genaNotifyThread, job in genaNotifyAllExt, job in genaNotifyAll,
job in genaInitNotifyExt, job in genaInitNotify, LocalAddr in
getlocalhostname.
(cherry picked from commit 7301f46269)
2012-03-05 10:33:30 -03:00
Fabrice Fontaine
f25c62e65c SF Bug Tracker id 3496934 - Memory leaks in getlocalhostname and UpnpGetIfInfo
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-03-05 01:25:42 PST

LocalSock is not closed if ioctl(LocalSock, SIOCGIFCONF, &ifConf);
returns an error.
(cherry picked from commit bd203e780e)
2012-03-05 10:33:30 -03:00
Fabrice Fontaine
078b4cf2c6 SF Bug Tracker id 3496933 - Out-of-bounds access in CheckOtherHTTPHeaders
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-03-05 01:15:34 PST

An out-of-bands access is raised because size of
RespInst->AcceptLanguageHeader is 200 and TmpBuf size is 180.
(cherry picked from commit 69f3fe2330)
2012-03-05 10:33:30 -03:00
Fabrice Fontaine
0eb4101492 Remove unused currentDevice variable in removeServiceTable
currentDevice is not used in this function.
(cherry picked from commit 52df3081df)
2012-03-05 10:33:30 -03:00
Fabrice Fontaine
1480623410 SF Bug Tracker id 3496581 - Memory leak in getServiceList
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-03-03 08:43:23 PST

serviceNodeList is not freed if
current->next = malloc(sizeof(service_info)); returns NULL.
(cherry picked from commit 71e77a5b27)
2012-03-05 10:33:30 -03:00
Fabrice Fontaine
b4cc5df288 SF Bug Tracker id 3495616 - Memory leak in ixmlElement_setAttributeNS
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-02-29 02:09:43 PST

newAttrNode is not freed if newAttr->n.nodeValue = strdup(value); returns
NULL or if ixmlElement_setAttributeNodeNS(element, newAttr, NULL) does
not return IXML_SUCCESS.
(cherry picked from commit a79a149e6a)
2012-03-05 10:33:30 -03:00
Fabrice Fontaine
89c174cc71 SF Bug Tracker id 3495286 - Double free in get_action_node
Submitted: Fabrice Fontaine ( ffontaine ) - 2012-02-28 04:27:54 PST

ixmlFreeDOMString(ActNodeName); is called twice if
ixmlParseBufferEx(ActNodeName, RespNode); does not return IXML_SUCCESS.
(cherry picked from commit 0693adc7dc)
2012-03-05 10:33:30 -03:00