Clarify the last argument of GetDescDocumentAndURL has size LINE_SIZE.

This commit is contained in:
Yoichi NAKAYAMA 2012-03-11 02:15:16 +09:00
parent bd7f83feb5
commit 19a23dafba
2 changed files with 10 additions and 9 deletions

View File

@ -8,6 +8,7 @@ Version 1.6.16
Treat large argument as error in UpnpAddVirtualDir. Treat large argument as error in UpnpAddVirtualDir.
Do not clear buffer before snprintf. Do not clear buffer before snprintf.
Clarify the last argument of GetDescDocumentAndURL has size LINE_SIZE.
For inet_ntop, use buffer with size INET6_ADDRSTRLEN or INET_ADDRSTRLEN. For inet_ntop, use buffer with size INET6_ADDRSTRLEN or INET_ADDRSTRLEN.
2012-03-10 Yoichi NAKAYAMA <yoichi.nakayama(at)gmail.com> 2012-03-10 Yoichi NAKAYAMA <yoichi.nakayama(at)gmail.com>

View File

@ -901,7 +901,7 @@ static int GetDescDocumentAndURL(
/* [out] . */ /* [out] . */
IXML_Document **xmlDoc, IXML_Document **xmlDoc,
/* [out] . */ /* [out] . */
char *descURL); char descURL[LINE_SIZE]);
#ifdef INCLUDE_DEVICE_APIS #ifdef INCLUDE_DEVICE_APIS
@ -1461,7 +1461,7 @@ static int GetDescDocumentAndURL(
int config_baseURL, int config_baseURL,
int AddressFamily, int AddressFamily,
IXML_Document **xmlDoc, IXML_Document **xmlDoc,
char *descURL) char descURL[LINE_SIZE])
{ {
int retVal = 0; int retVal = 0;
char *membuf = NULL; char *membuf = NULL;
@ -1559,12 +1559,12 @@ static int GetDescDocumentAndURL(
} }
} else { } else {
/* Manual */ /* Manual */
if (strlen(description) > (LINE_SIZE - 1)) { if (strlen(description) > LINE_SIZE - 1) {
ixmlDocument_free(*xmlDoc); ixmlDocument_free(*xmlDoc);
return UPNP_E_URL_TOO_BIG; return UPNP_E_URL_TOO_BIG;
} }
strncpy(descURL, description, strlen(description)); strncpy(descURL, description, LINE_SIZE - 1);
descURL[strlen(description)] = '\0'; descURL[LINE_SIZE - 1] = '\0';
} }
assert(*xmlDoc != NULL); assert(*xmlDoc != NULL);
@ -1580,7 +1580,7 @@ static int GetDescDocumentAndURL(
int config_baseURL, int config_baseURL,
int AddressFamily, int AddressFamily,
IXML_Document **xmlDoc, IXML_Document **xmlDoc,
char *descURL) char descURL[LINE_SIZE])
{ {
int retVal = 0; int retVal = 0;
@ -1592,11 +1592,11 @@ static int GetDescDocumentAndURL(
return UPNP_E_INVALID_PARAM; return UPNP_E_INVALID_PARAM;
} }
if (strlen(description) > (LINE_SIZE - 1)) { if (strlen(description) > LINE_SIZE - 1) {
return UPNP_E_URL_TOO_BIG; return UPNP_E_URL_TOO_BIG;
} }
strncpy(descURL, description, strlen(description)); strncpy(descURL, description, LINE_SIZE - 1);
descURL[strlen(description)] = '\0'; descURL[LINE_SIZE - 1] = '\0';
retVal = UpnpDownloadXmlDoc(description, xmlDoc); retVal = UpnpDownloadXmlDoc(description, xmlDoc);
if (retVal != UPNP_E_SUCCESS) { if (retVal != UPNP_E_SUCCESS) {