SF Bug Tracker [ 3022490 ] String declaration fix for patch applied in 3007407

Hello,

	When my patch for tracker ID 3007407 was accepted, the definition of the
	serviceList string was changed from

	#define SERVICELIST_STR "serviceList"

	to

	static const char *SERVICELIST_STR = "serviceList";

	During internal code review of the final patch, it was pointed out that 
	sizeof(SERVICELIST_STR) == 4 since SERVICELIST_STR is now declared as
	a pointer instead of an array.

	If you wish to use a variable instead of a define, I suggest the
	following instead:

	static const char SERVICELIST_STR[] = "serviceList";

	Thanks,
	Chuck Thomason



git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@556 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
Marcelo Roberto Jimenez 2010-06-28 20:36:30 +00:00
parent fab22807c0
commit b2e38b2fca
2 changed files with 27 additions and 2 deletions

View File

@ -211,6 +211,31 @@ Version 1.8.0
Version 1.6.7
*******************************************************************************
2010-06-28 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
SF Bug Tracker [ 3022490 ] String declaration fix for patch applied in 3007407
Hello,
When my patch for tracker ID 3007407 was accepted, the definition of the
serviceList string was changed from
#define SERVICELIST_STR "serviceList"
to
static const char *SERVICELIST_STR = "serviceList";
During internal code review of the final patch, it was pointed out that
sizeof(SERVICELIST_STR) == 4 since SERVICELIST_STR is now declared as
a pointer instead of an array.
If you wish to use a variable instead of a define, I suggest the
following instead:
static const char SERVICELIST_STR[] = "serviceList";
Thanks,
Chuck Thomason
2010-06-10 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
SF Bug Tracker [ 3007407 ] Service traversal issue in AdvertiseAndReply()
Submitted: Chuck Thomason ( cyt4 ) - 2010-05-26 15:07:39 UTC

View File

@ -96,7 +96,7 @@ struct SSDPSockArray {
* Returns: int
* UPNP_E_SUCCESS if successful else appropriate error
***************************************************************************/
static const char *SERVICELIST_STR = "serviceList";
static const char SERVICELIST_STR[] = "serviceList";
int AdvertiseAndReply(
IN int AdFlag,
@ -289,7 +289,7 @@ int AdvertiseAndReply(
tmpNode = ixmlNode_getFirstChild(tmpNode);
while (tmpNode) {
dbgStr = ixmlNode_getNodeName(tmpNode);
if (!strncmp(dbgStr, SERVICELIST_STR, sizeof(SERVICELIST_STR))) {
if (!strncmp(dbgStr, SERVICELIST_STR, sizeof SERVICELIST_STR)) {
break;
}
tmpNode = ixmlNode_getNextSibling(tmpNode);