Remove more implicit casts in upnp part
Remove more "implicit integer or enum conversions" errors as well as dead code.
This commit is contained in:
parent
8e39b2af85
commit
c40d2bc0c9
@ -2,6 +2,13 @@
|
|||||||
Version 1.6.16
|
Version 1.6.16
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
|
2012-03-11 Fabrice Fontaine <fabrice.fontaine(at)orange.com>
|
||||||
|
|
||||||
|
Remove more implicit casts in upnp part
|
||||||
|
|
||||||
|
Remove more "implicit integer or enum conversions" errors as well as
|
||||||
|
dead code.
|
||||||
|
|
||||||
2012-03-11 Fabrice Fontaine <fabrice.fontaine(at)orange.com>
|
2012-03-11 Fabrice Fontaine <fabrice.fontaine(at)orange.com>
|
||||||
|
|
||||||
Remove more implicit casts in upnp part
|
Remove more implicit casts in upnp part
|
||||||
|
@ -77,7 +77,7 @@ struct SUpnpString
|
|||||||
UpnpString *UpnpString_new()
|
UpnpString *UpnpString_new()
|
||||||
{
|
{
|
||||||
/* All bytes are zero, and so is the length of the string. */
|
/* All bytes are zero, and so is the length of the string. */
|
||||||
struct SUpnpString *p = calloc(1, sizeof (struct SUpnpString));
|
struct SUpnpString *p = calloc((size_t)1, sizeof (struct SUpnpString));
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
goto error_handler1;
|
goto error_handler1;
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ UpnpString *UpnpString_new()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This byte is zero, calloc does initialize it. */
|
/* This byte is zero, calloc does initialize it. */
|
||||||
p->m_string = calloc(1, 1);
|
p->m_string = calloc((size_t)1, (size_t)1);
|
||||||
if (p->m_string == NULL) {
|
if (p->m_string == NULL) {
|
||||||
goto error_handler2;
|
goto error_handler2;
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ void UpnpString_delete(UpnpString *p)
|
|||||||
|
|
||||||
if (!q) return;
|
if (!q) return;
|
||||||
|
|
||||||
q->m_length = 0;
|
q->m_length = (size_t)0;
|
||||||
|
|
||||||
free(q->m_string);
|
free(q->m_string);
|
||||||
q->m_string = NULL;
|
q->m_string = NULL;
|
||||||
@ -116,7 +116,7 @@ void UpnpString_delete(UpnpString *p)
|
|||||||
|
|
||||||
UpnpString *UpnpString_dup(const UpnpString *p)
|
UpnpString *UpnpString_dup(const UpnpString *p)
|
||||||
{
|
{
|
||||||
struct SUpnpString *q = calloc(1, sizeof (struct SUpnpString));
|
struct SUpnpString *q = calloc((size_t)1, sizeof (struct SUpnpString));
|
||||||
if (q == NULL) {
|
if (q == NULL) {
|
||||||
goto error_handler1;
|
goto error_handler1;
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ error_handler1:
|
|||||||
|
|
||||||
void UpnpString_clear(UpnpString *p)
|
void UpnpString_clear(UpnpString *p)
|
||||||
{
|
{
|
||||||
((struct SUpnpString *)p)->m_length = 0;
|
((struct SUpnpString *)p)->m_length = (size_t)0;
|
||||||
/* No need to realloc now, will do later when needed. */
|
/* No need to realloc now, will do later when needed. */
|
||||||
((struct SUpnpString *)p)->m_string[0] = 0;
|
((struct SUpnpString *)p)->m_string[0] = 0;
|
||||||
}
|
}
|
||||||
|
@ -442,7 +442,7 @@ int UpnpInit(const char *HostIP, unsigned short DestPort)
|
|||||||
|
|
||||||
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
|
||||||
"UpnpInit with HostIP=%s, DestPort=%d.\n",
|
"UpnpInit with HostIP=%s, DestPort=%d.\n",
|
||||||
HostIP ? HostIP : "", DestPort);
|
HostIP ? HostIP : "", (int)DestPort);
|
||||||
|
|
||||||
/* Verify HostIP, if provided, or find it ourselves. */
|
/* Verify HostIP, if provided, or find it ourselves. */
|
||||||
memset(gIF_IPV4, 0, sizeof(gIF_IPV4));
|
memset(gIF_IPV4, 0, sizeof(gIF_IPV4));
|
||||||
@ -467,7 +467,7 @@ int UpnpInit(const char *HostIP, unsigned short DestPort)
|
|||||||
|
|
||||||
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_INFO, API, __FILE__, __LINE__,
|
||||||
"Host Ip: %s Host Port: %d\n", gIF_IPV4,
|
"Host Ip: %s Host Port: %d\n", gIF_IPV4,
|
||||||
LOCAL_PORT_V4);
|
(int)LOCAL_PORT_V4);
|
||||||
|
|
||||||
exit_function:
|
exit_function:
|
||||||
ithread_mutex_unlock(&gSDKInitMutex);
|
ithread_mutex_unlock(&gSDKInitMutex);
|
||||||
@ -653,7 +653,7 @@ int UpnpFinish(void)
|
|||||||
unsigned short UpnpGetServerPort(void)
|
unsigned short UpnpGetServerPort(void)
|
||||||
{
|
{
|
||||||
if (UpnpSdkInit != 1)
|
if (UpnpSdkInit != 1)
|
||||||
return 0;
|
return 0u;
|
||||||
|
|
||||||
return LOCAL_PORT_V4;
|
return LOCAL_PORT_V4;
|
||||||
}
|
}
|
||||||
@ -662,7 +662,7 @@ unsigned short UpnpGetServerPort(void)
|
|||||||
unsigned short UpnpGetServerPort6(void)
|
unsigned short UpnpGetServerPort6(void)
|
||||||
{
|
{
|
||||||
if (UpnpSdkInit != 1)
|
if (UpnpSdkInit != 1)
|
||||||
return 0;
|
return 0u;
|
||||||
|
|
||||||
return LOCAL_PORT_V6;
|
return LOCAL_PORT_V6;
|
||||||
}
|
}
|
||||||
@ -767,7 +767,7 @@ int UpnpRegisterRootDevice(
|
|||||||
if (Hnd == NULL ||
|
if (Hnd == NULL ||
|
||||||
Fun == NULL ||
|
Fun == NULL ||
|
||||||
DescUrl == NULL ||
|
DescUrl == NULL ||
|
||||||
strlen(DescUrl) == 0) {
|
strlen(DescUrl) == (size_t)0) {
|
||||||
retVal = UPNP_E_INVALID_PARAM;
|
retVal = UPNP_E_INVALID_PARAM;
|
||||||
goto exit_function;
|
goto exit_function;
|
||||||
}
|
}
|
||||||
@ -1091,7 +1091,7 @@ int UpnpRegisterRootDevice4(
|
|||||||
if (Hnd == NULL ||
|
if (Hnd == NULL ||
|
||||||
Fun == NULL ||
|
Fun == NULL ||
|
||||||
DescUrl == NULL ||
|
DescUrl == NULL ||
|
||||||
strlen(DescUrl) == 0 ||
|
strlen(DescUrl) == (size_t)0 ||
|
||||||
(AddressFamily != AF_INET && AddressFamily != AF_INET6)) {
|
(AddressFamily != AF_INET && AddressFamily != AF_INET6)) {
|
||||||
retVal = UPNP_E_INVALID_PARAM;
|
retVal = UPNP_E_INVALID_PARAM;
|
||||||
goto exit_function;
|
goto exit_function;
|
||||||
@ -1481,15 +1481,16 @@ static int GetDescDocumentAndURL(
|
|||||||
if (description == NULL)
|
if (description == NULL)
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
/* non-URL description must have configuration specified */
|
/* non-URL description must have configuration specified */
|
||||||
if (descriptionType != UPNPREG_URL_DESC && !config_baseURL)
|
if (descriptionType != (enum Upnp_DescType_e)UPNPREG_URL_DESC &&
|
||||||
|
!config_baseURL)
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
/* Get XML doc and last modified time */
|
/* Get XML doc and last modified time */
|
||||||
if (descriptionType == UPNPREG_URL_DESC) {
|
if (descriptionType == (enum Upnp_DescType_e)UPNPREG_URL_DESC) {
|
||||||
retVal = UpnpDownloadXmlDoc(description, xmlDoc);
|
retVal = UpnpDownloadXmlDoc(description, xmlDoc);
|
||||||
if (retVal != UPNP_E_SUCCESS)
|
if (retVal != UPNP_E_SUCCESS)
|
||||||
return retVal;
|
return retVal;
|
||||||
last_modified = time(NULL);
|
last_modified = time(NULL);
|
||||||
} else if (descriptionType == UPNPREG_FILENAME_DESC) {
|
} else if (descriptionType == (enum Upnp_DescType_e)UPNPREG_FILENAME_DESC) {
|
||||||
retVal = stat(description, &file_info);
|
retVal = stat(description, &file_info);
|
||||||
if (retVal == -1)
|
if (retVal == -1)
|
||||||
return UPNP_E_FILE_NOT_FOUND;
|
return UPNP_E_FILE_NOT_FOUND;
|
||||||
@ -1498,12 +1499,12 @@ static int GetDescDocumentAndURL(
|
|||||||
fp = fopen(description, "rb");
|
fp = fopen(description, "rb");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return UPNP_E_FILE_NOT_FOUND;
|
return UPNP_E_FILE_NOT_FOUND;
|
||||||
membuf = (char *)malloc(fileLen + 1);
|
membuf = (char *)malloc(fileLen + (size_t)1);
|
||||||
if (membuf == NULL) {
|
if (membuf == NULL) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
return UPNP_E_OUTOF_MEMORY;
|
||||||
}
|
}
|
||||||
num_read = fread(membuf, 1, fileLen, fp);
|
num_read = fread(membuf, (size_t)1, fileLen, fp);
|
||||||
if (num_read != fileLen) {
|
if (num_read != fileLen) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
free(membuf);
|
free(membuf);
|
||||||
@ -1513,14 +1514,15 @@ static int GetDescDocumentAndURL(
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
rc = ixmlParseBufferEx(membuf, xmlDoc);
|
rc = ixmlParseBufferEx(membuf, xmlDoc);
|
||||||
free(membuf);
|
free(membuf);
|
||||||
} else if (descriptionType == UPNPREG_BUF_DESC) {
|
} else if (descriptionType == (enum Upnp_DescType_e)UPNPREG_BUF_DESC) {
|
||||||
last_modified = time(NULL);
|
last_modified = time(NULL);
|
||||||
rc = ixmlParseBufferEx(description, xmlDoc);
|
rc = ixmlParseBufferEx(description, xmlDoc);
|
||||||
} else {
|
} else {
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc != IXML_SUCCESS && descriptionType != UPNPREG_URL_DESC) {
|
if (rc != IXML_SUCCESS &&
|
||||||
|
descriptionType != (enum Upnp_DescType_e)UPNPREG_URL_DESC) {
|
||||||
if (rc == IXML_INSUFFICIENT_MEMORY)
|
if (rc == IXML_INSUFFICIENT_MEMORY)
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
return UPNP_E_OUTOF_MEMORY;
|
||||||
else
|
else
|
||||||
@ -1528,7 +1530,7 @@ static int GetDescDocumentAndURL(
|
|||||||
}
|
}
|
||||||
/* Determine alias */
|
/* Determine alias */
|
||||||
if (config_baseURL) {
|
if (config_baseURL) {
|
||||||
if (descriptionType == UPNPREG_BUF_DESC) {
|
if (descriptionType == (enum Upnp_DescType_e)UPNPREG_BUF_DESC) {
|
||||||
strncpy(aliasStr, "description.xml",
|
strncpy(aliasStr, "description.xml",
|
||||||
sizeof(aliasStr) - 1);
|
sizeof(aliasStr) - 1);
|
||||||
} else {
|
} else {
|
||||||
@ -1586,7 +1588,8 @@ static int GetDescDocumentAndURL(
|
|||||||
{
|
{
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
|
|
||||||
if (descriptionType != UPNPREG_URL_DESC || config_baseURL) {
|
if (descriptionType != (enum Upnp_DescType_e)UPNPREG_URL_DESC ||
|
||||||
|
config_baseURL) {
|
||||||
return UPNP_E_NO_WEB_SERVER;
|
return UPNP_E_NO_WEB_SERVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1594,7 +1597,7 @@ static int GetDescDocumentAndURL(
|
|||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(description) > LINE_SIZE - 1) {
|
if (strlen(description) > LINE_SIZE - (size_t)1) {
|
||||||
return UPNP_E_URL_TOO_BIG;
|
return UPNP_E_URL_TOO_BIG;
|
||||||
}
|
}
|
||||||
strncpy(descURL, description, LINE_SIZE - 1);
|
strncpy(descURL, description, LINE_SIZE - 1);
|
||||||
@ -3333,7 +3336,7 @@ int UpnpGetIfInfo(const char *IfName)
|
|||||||
return UPNP_E_INIT;
|
return UPNP_E_INIT;
|
||||||
}
|
}
|
||||||
/* Get the interface configuration information... */
|
/* Get the interface configuration information... */
|
||||||
ifConf.ifc_len = sizeof szBuffer;
|
ifConf.ifc_len = (int)sizeof szBuffer;
|
||||||
ifConf.ifc_ifcu.ifcu_buf = (caddr_t) szBuffer;
|
ifConf.ifc_ifcu.ifcu_buf = (caddr_t) szBuffer;
|
||||||
|
|
||||||
if (ioctl(LocalSock, SIOCGIFCONF, &ifConf) < 0) {
|
if (ioctl(LocalSock, SIOCGIFCONF, &ifConf) < 0) {
|
||||||
@ -3343,7 +3346,7 @@ int UpnpGetIfInfo(const char *IfName)
|
|||||||
return UPNP_E_INIT;
|
return UPNP_E_INIT;
|
||||||
}
|
}
|
||||||
/* Cycle through the list of interfaces looking for IP addresses. */
|
/* Cycle through the list of interfaces looking for IP addresses. */
|
||||||
for (i = 0; i < (size_t)ifConf.ifc_len;) {
|
for (i = (size_t)0; i < (size_t)ifConf.ifc_len;) {
|
||||||
struct ifreq *pifReq =
|
struct ifreq *pifReq =
|
||||||
(struct ifreq *)((caddr_t) ifConf.ifc_req + i);
|
(struct ifreq *)((caddr_t) ifConf.ifc_req + i);
|
||||||
i += sizeof *pifReq;
|
i += sizeof *pifReq;
|
||||||
@ -3426,7 +3429,7 @@ int UpnpGetIfInfo(const char *IfName)
|
|||||||
(gIF_IPV6_ULA_GUA) - 1);
|
(gIF_IPV6_ULA_GUA) - 1);
|
||||||
} else if (IN6_IS_ADDR_GLOBAL(&v6_addr)
|
} else if (IN6_IS_ADDR_GLOBAL(&v6_addr)
|
||||||
&& strlen(gIF_IPV6_ULA_GUA)
|
&& strlen(gIF_IPV6_ULA_GUA)
|
||||||
== 0) {
|
== (size_t)0) {
|
||||||
/* got a GUA, should store it while no ULA is found */
|
/* got a GUA, should store it while no ULA is found */
|
||||||
memset(gIF_IPV6_ULA_GUA, 0,
|
memset(gIF_IPV6_ULA_GUA, 0,
|
||||||
sizeof(gIF_IPV6_ULA_GUA));
|
sizeof(gIF_IPV6_ULA_GUA));
|
||||||
@ -3435,7 +3438,7 @@ int UpnpGetIfInfo(const char *IfName)
|
|||||||
(gIF_IPV6_ULA_GUA) - 1);
|
(gIF_IPV6_ULA_GUA) - 1);
|
||||||
} else
|
} else
|
||||||
if (IN6_IS_ADDR_LINKLOCAL(&v6_addr)
|
if (IN6_IS_ADDR_LINKLOCAL(&v6_addr)
|
||||||
&& strlen(gIF_IPV6) == 0) {
|
&& strlen(gIF_IPV6) == (size_t)0) {
|
||||||
/* got a Link local IPv6 address. */
|
/* got a Link local IPv6 address. */
|
||||||
memset(gIF_IPV6, 0,
|
memset(gIF_IPV6, 0,
|
||||||
sizeof(gIF_IPV6));
|
sizeof(gIF_IPV6));
|
||||||
@ -3773,7 +3776,7 @@ int getlocalhostname(char *out, size_t out_len)
|
|||||||
return UPNP_E_INIT;
|
return UPNP_E_INIT;
|
||||||
}
|
}
|
||||||
/* Get the interface configuration information... */
|
/* Get the interface configuration information... */
|
||||||
ifConf.ifc_len = sizeof szBuffer;
|
ifConf.ifc_len = (int)sizeof szBuffer;
|
||||||
ifConf.ifc_ifcu.ifcu_buf = (caddr_t) szBuffer;
|
ifConf.ifc_ifcu.ifcu_buf = (caddr_t) szBuffer;
|
||||||
nResult = ioctl(LocalSock, SIOCGIFCONF, &ifConf);
|
nResult = ioctl(LocalSock, SIOCGIFCONF, &ifConf);
|
||||||
if (nResult < 0) {
|
if (nResult < 0) {
|
||||||
@ -3784,7 +3787,7 @@ int getlocalhostname(char *out, size_t out_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Cycle through the list of interfaces looking for IP addresses. */
|
/* Cycle through the list of interfaces looking for IP addresses. */
|
||||||
for (i = 0; i < (long unsigned int)ifConf.ifc_len && j < DEFAULT_INTERFACE; ) {
|
for (i = 0lu; i < (long unsigned int)ifConf.ifc_len && j < DEFAULT_INTERFACE; ) {
|
||||||
struct ifreq *pifReq =
|
struct ifreq *pifReq =
|
||||||
(struct ifreq *)((caddr_t)ifConf.ifc_req + i);
|
(struct ifreq *)((caddr_t)ifConf.ifc_req + i);
|
||||||
i += sizeof *pifReq;
|
i += sizeof *pifReq;
|
||||||
@ -3877,7 +3880,7 @@ int UpnpAddVirtualDir(const char *newDirName)
|
|||||||
return UPNP_E_FINISH;
|
return UPNP_E_FINISH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( newDirName == NULL ) || ( strlen( newDirName ) == 0 ) ) {
|
if( ( newDirName == NULL ) || ( strlen( newDirName ) == ( size_t ) 0 ) ) {
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4040,7 +4043,7 @@ int UpnpIsWebserverEnabled(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bWebServerState == WEB_SERVER_ENABLED;
|
return bWebServerState == (WebServerState)WEB_SERVER_ENABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
int UpnpSetVirtualDirCallbacks(struct UpnpVirtualDirCallbacks *callbacks)
|
int UpnpSetVirtualDirCallbacks(struct UpnpVirtualDirCallbacks *callbacks)
|
||||||
|
@ -127,7 +127,7 @@ str_int_entry Http_Header_Names[NUM_HTTP_HEADER_NAMES] = {
|
|||||||
************************************************************************/
|
************************************************************************/
|
||||||
static UPNP_INLINE void scanner_init(OUT scanner_t *scanner, IN membuffer *bufptr)
|
static UPNP_INLINE void scanner_init(OUT scanner_t *scanner, IN membuffer *bufptr)
|
||||||
{
|
{
|
||||||
scanner->cursor = 0;
|
scanner->cursor = (size_t)0;
|
||||||
scanner->msg = bufptr;
|
scanner->msg = bufptr;
|
||||||
scanner->entire_msg_loaded = FALSE;
|
scanner->entire_msg_loaded = FALSE;
|
||||||
}
|
}
|
||||||
@ -143,7 +143,7 @@ static UPNP_INLINE void scanner_init(OUT scanner_t *scanner, IN membuffer *bufpt
|
|||||||
************************************************************************/
|
************************************************************************/
|
||||||
static UPNP_INLINE int is_separator_char(IN char c)
|
static UPNP_INLINE int is_separator_char(IN char c)
|
||||||
{
|
{
|
||||||
return strchr(" \t()<>@,;:\\\"/[]?={}", c) != NULL;
|
return strchr(" \t()<>@,;:\\\"/[]?={}", (int)c) != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
@ -249,7 +249,7 @@ static parse_status_t scanner_get_token(
|
|||||||
/* possibly more valid chars */
|
/* possibly more valid chars */
|
||||||
return PARSE_INCOMPLETE;
|
return PARSE_INCOMPLETE;
|
||||||
/* calc token length */
|
/* calc token length */
|
||||||
token->length = (size_t)(cursor - token->buf);
|
token->length = (size_t)cursor - (size_t)token->buf;
|
||||||
} else if (c == ' ' || c == '\t') {
|
} else if (c == ' ' || c == '\t') {
|
||||||
token->buf = cursor++;
|
token->buf = cursor++;
|
||||||
token_type = TT_WHITESPACE;
|
token_type = TT_WHITESPACE;
|
||||||
@ -258,7 +258,7 @@ static parse_status_t scanner_get_token(
|
|||||||
if (!scanner->entire_msg_loaded && cursor == null_terminator)
|
if (!scanner->entire_msg_loaded && cursor == null_terminator)
|
||||||
/* possibly more chars */
|
/* possibly more chars */
|
||||||
return PARSE_INCOMPLETE;
|
return PARSE_INCOMPLETE;
|
||||||
token->length = (size_t)(cursor - token->buf);
|
token->length = (size_t)cursor - (size_t)token->buf;
|
||||||
} else if (c == TOKCHAR_CR) {
|
} else if (c == TOKCHAR_CR) {
|
||||||
/* scan CRLF */
|
/* scan CRLF */
|
||||||
token->buf = cursor++;
|
token->buf = cursor++;
|
||||||
@ -268,16 +268,16 @@ static parse_status_t scanner_get_token(
|
|||||||
if (*cursor != TOKCHAR_LF) {
|
if (*cursor != TOKCHAR_LF) {
|
||||||
/* couldn't match CRLF; match as CR */
|
/* couldn't match CRLF; match as CR */
|
||||||
token_type = TT_CTRL; /* ctrl char */
|
token_type = TT_CTRL; /* ctrl char */
|
||||||
token->length = 1;
|
token->length = (size_t)1;
|
||||||
} else {
|
} else {
|
||||||
/* got CRLF */
|
/* got CRLF */
|
||||||
token->length = 2;
|
token->length = (size_t)2;
|
||||||
token_type = TT_CRLF;
|
token_type = TT_CRLF;
|
||||||
cursor++;
|
cursor++;
|
||||||
}
|
}
|
||||||
} else if (c == TOKCHAR_LF) { /* accept \n as CRLF */
|
} else if (c == TOKCHAR_LF) { /* accept \n as CRLF */
|
||||||
token->buf = cursor++;
|
token->buf = cursor++;
|
||||||
token->length = 1;
|
token->length = (size_t)1;
|
||||||
token_type = TT_CRLF;
|
token_type = TT_CRLF;
|
||||||
} else if (c == '"') {
|
} else if (c == '"') {
|
||||||
/* quoted text */
|
/* quoted text */
|
||||||
@ -304,7 +304,7 @@ static parse_status_t scanner_get_token(
|
|||||||
return PARSE_FAILURE;
|
return PARSE_FAILURE;
|
||||||
}
|
}
|
||||||
if (got_end_quote)
|
if (got_end_quote)
|
||||||
token->length = (size_t)(cursor - token->buf);
|
token->length = (size_t)cursor - (size_t)token->buf;
|
||||||
else { /* incomplete */
|
else { /* incomplete */
|
||||||
|
|
||||||
assert(cursor == null_terminator);
|
assert(cursor == null_terminator);
|
||||||
@ -314,12 +314,12 @@ static parse_status_t scanner_get_token(
|
|||||||
/* scan separator */
|
/* scan separator */
|
||||||
token->buf = cursor++;
|
token->buf = cursor++;
|
||||||
token_type = TT_SEPARATOR;
|
token_type = TT_SEPARATOR;
|
||||||
token->length = 1;
|
token->length = (size_t)1;
|
||||||
} else if (is_control_char(c)) {
|
} else if (is_control_char(c)) {
|
||||||
/* scan ctrl char */
|
/* scan ctrl char */
|
||||||
token->buf = cursor++;
|
token->buf = cursor++;
|
||||||
token_type = TT_CTRL;
|
token_type = TT_CTRL;
|
||||||
token->length = 1;
|
token->length = (size_t)1;
|
||||||
} else
|
} else
|
||||||
return PARSE_FAILURE;
|
return PARSE_FAILURE;
|
||||||
|
|
||||||
@ -406,7 +406,7 @@ void httpmsg_init(INOUT http_message_t *msg)
|
|||||||
{
|
{
|
||||||
msg->initialized = 1;
|
msg->initialized = 1;
|
||||||
msg->entity.buf = NULL;
|
msg->entity.buf = NULL;
|
||||||
msg->entity.length = 0;
|
msg->entity.length = ( size_t ) 0;
|
||||||
ListInit( &msg->headers, httpmsg_compare, httpheader_free );
|
ListInit( &msg->headers, httpmsg_compare, httpheader_free );
|
||||||
membuffer_init( &msg->msg );
|
membuffer_init( &msg->msg );
|
||||||
membuffer_init( &msg->status_msg );
|
membuffer_init( &msg->status_msg );
|
||||||
@ -534,7 +534,8 @@ static UPNP_INLINE parse_status_t skip_blank_lines(INOUT scanner_t *scanner)
|
|||||||
do {
|
do {
|
||||||
status = scanner_get_token(scanner, &token, &tok_type);
|
status = scanner_get_token(scanner, &token, &tok_type);
|
||||||
} while (status == (parse_status_t)PARSE_OK &&
|
} while (status == (parse_status_t)PARSE_OK &&
|
||||||
(tok_type == TT_WHITESPACE || tok_type == TT_CRLF));
|
(tok_type == (token_type_t)TT_WHITESPACE ||
|
||||||
|
tok_type == (token_type_t)TT_CRLF));
|
||||||
if (status == (parse_status_t)PARSE_OK) {
|
if (status == (parse_status_t)PARSE_OK) {
|
||||||
/* pushback a non-whitespace token */
|
/* pushback a non-whitespace token */
|
||||||
scanner->cursor -= token.length;
|
scanner->cursor -= token.length;
|
||||||
@ -573,13 +574,13 @@ static UPNP_INLINE parse_status_t skip_lws(INOUT scanner_t *scanner)
|
|||||||
/* get CRLF or WS */
|
/* get CRLF or WS */
|
||||||
status = scanner_get_token( scanner, &token, &tok_type );
|
status = scanner_get_token( scanner, &token, &tok_type );
|
||||||
if( status == ( parse_status_t ) PARSE_OK ) {
|
if( status == ( parse_status_t ) PARSE_OK ) {
|
||||||
if( tok_type == TT_CRLF ) {
|
if( tok_type == ( token_type_t ) TT_CRLF ) {
|
||||||
/* get WS */
|
/* get WS */
|
||||||
status = scanner_get_token( scanner, &token, &tok_type );
|
status = scanner_get_token( scanner, &token, &tok_type );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( status == ( parse_status_t ) PARSE_OK &&
|
if( status == ( parse_status_t ) PARSE_OK &&
|
||||||
tok_type == TT_WHITESPACE ) {
|
tok_type == ( token_type_t ) TT_WHITESPACE ) {
|
||||||
matched = TRUE;
|
matched = TRUE;
|
||||||
} else {
|
} else {
|
||||||
/* did not match LWS; pushback token(s) */
|
/* did not match LWS; pushback token(s) */
|
||||||
@ -626,13 +627,14 @@ static UPNP_INLINE parse_status_t match_non_ws_string(
|
|||||||
|
|
||||||
save_cursor = scanner->cursor;
|
save_cursor = scanner->cursor;
|
||||||
|
|
||||||
str->length = 0;
|
str->length = ( size_t ) 0;
|
||||||
str->buf = scanner_get_str( scanner ); /* point to next char in input */
|
str->buf = scanner_get_str( scanner ); /* point to next char in input */
|
||||||
|
|
||||||
while( !done ) {
|
while( !done ) {
|
||||||
status = scanner_get_token( scanner, &token, &tok_type );
|
status = scanner_get_token( scanner, &token, &tok_type );
|
||||||
if( status == ( parse_status_t ) PARSE_OK &&
|
if( status == ( parse_status_t ) PARSE_OK &&
|
||||||
tok_type != TT_WHITESPACE && tok_type != TT_CRLF ) {
|
tok_type != ( token_type_t ) TT_WHITESPACE &&
|
||||||
|
tok_type != ( token_type_t ) TT_CRLF ) {
|
||||||
/* append non-ws token */
|
/* append non-ws token */
|
||||||
str->length += token.length;
|
str->length += token.length;
|
||||||
} else {
|
} else {
|
||||||
@ -646,9 +648,10 @@ static UPNP_INLINE parse_status_t match_non_ws_string(
|
|||||||
}
|
}
|
||||||
/* tolerate 'incomplete' msg */
|
/* tolerate 'incomplete' msg */
|
||||||
if( status == ( parse_status_t ) PARSE_OK ||
|
if( status == ( parse_status_t ) PARSE_OK ||
|
||||||
( status == ( parse_status_t ) PARSE_INCOMPLETE && scanner->entire_msg_loaded )
|
( status == ( parse_status_t ) PARSE_INCOMPLETE &&
|
||||||
|
scanner->entire_msg_loaded )
|
||||||
) {
|
) {
|
||||||
if( str->length == 0 ) {
|
if( str->length == ( size_t ) 0 ) {
|
||||||
/* no strings found */
|
/* no strings found */
|
||||||
return PARSE_NO_MATCH;
|
return PARSE_NO_MATCH;
|
||||||
} else {
|
} else {
|
||||||
@ -689,7 +692,7 @@ static UPNP_INLINE parse_status_t match_raw_value(
|
|||||||
parse_status_t status;
|
parse_status_t status;
|
||||||
int done = FALSE;
|
int done = FALSE;
|
||||||
int saw_crlf = FALSE;
|
int saw_crlf = FALSE;
|
||||||
size_t pos_at_crlf = 0;
|
size_t pos_at_crlf = ( size_t ) 0;
|
||||||
size_t save_pos;
|
size_t save_pos;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
@ -697,13 +700,13 @@ static UPNP_INLINE parse_status_t match_raw_value(
|
|||||||
|
|
||||||
/* value points to start of input */
|
/* value points to start of input */
|
||||||
raw_value->buf = scanner_get_str( scanner );
|
raw_value->buf = scanner_get_str( scanner );
|
||||||
raw_value->length = 0;
|
raw_value->length = ( size_t ) 0;
|
||||||
|
|
||||||
while( !done ) {
|
while( !done ) {
|
||||||
status = scanner_get_token( scanner, &token, &tok_type );
|
status = scanner_get_token( scanner, &token, &tok_type );
|
||||||
if( status == ( parse_status_t ) PARSE_OK ) {
|
if( status == ( parse_status_t ) PARSE_OK ) {
|
||||||
if( !saw_crlf ) {
|
if( !saw_crlf ) {
|
||||||
if( tok_type == TT_CRLF ) {
|
if( tok_type == ( token_type_t ) TT_CRLF ) {
|
||||||
/* CRLF could end value */
|
/* CRLF could end value */
|
||||||
saw_crlf = TRUE;
|
saw_crlf = TRUE;
|
||||||
|
|
||||||
@ -714,7 +717,7 @@ static UPNP_INLINE parse_status_t match_raw_value(
|
|||||||
raw_value->length += token.length;
|
raw_value->length += token.length;
|
||||||
} else /* already seen CRLF */
|
} else /* already seen CRLF */
|
||||||
{
|
{
|
||||||
if( tok_type == TT_WHITESPACE ) {
|
if( tok_type == ( token_type_t ) TT_WHITESPACE ) {
|
||||||
/* start again; forget CRLF */
|
/* start again; forget CRLF */
|
||||||
saw_crlf = FALSE;
|
saw_crlf = FALSE;
|
||||||
raw_value->length += token.length;
|
raw_value->length += token.length;
|
||||||
@ -735,9 +738,9 @@ static UPNP_INLINE parse_status_t match_raw_value(
|
|||||||
|
|
||||||
if( status == ( parse_status_t ) PARSE_OK ) {
|
if( status == ( parse_status_t ) PARSE_OK ) {
|
||||||
/* trim whitespace on right side of value */
|
/* trim whitespace on right side of value */
|
||||||
while( raw_value->length > 0 ) {
|
while( raw_value->length > ( size_t ) 0 ) {
|
||||||
/* get last char */
|
/* get last char */
|
||||||
c = raw_value->buf[raw_value->length - 1];
|
c = raw_value->buf[raw_value->length - ( size_t ) 1];
|
||||||
|
|
||||||
if( c != ' ' && c != '\t' &&
|
if( c != ' ' && c != '\t' &&
|
||||||
c != TOKCHAR_CR && c != TOKCHAR_LF ) {
|
c != TOKCHAR_CR && c != TOKCHAR_LF ) {
|
||||||
@ -786,7 +789,7 @@ static UPNP_INLINE parse_status_t match_int(
|
|||||||
save_pos = scanner->cursor;
|
save_pos = scanner->cursor;
|
||||||
status = scanner_get_token(scanner, &token, &tok_type);
|
status = scanner_get_token(scanner, &token, &tok_type);
|
||||||
if (status == (parse_status_t)PARSE_OK) {
|
if (status == (parse_status_t)PARSE_OK) {
|
||||||
if (tok_type == TT_IDENTIFIER) {
|
if (tok_type == (token_type_t)TT_IDENTIFIER) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
num = strtol(token.buf, &end_ptr, base);
|
num = strtol(token.buf, &end_ptr, base);
|
||||||
/* all and only those chars in token should be used for num */
|
/* all and only those chars in token should be used for num */
|
||||||
@ -840,7 +843,8 @@ read_until_crlf( INOUT scanner_t * scanner,
|
|||||||
/* read until we hit a crlf */
|
/* read until we hit a crlf */
|
||||||
do {
|
do {
|
||||||
status = scanner_get_token( scanner, &token, &tok_type );
|
status = scanner_get_token( scanner, &token, &tok_type );
|
||||||
} while( status == ( parse_status_t ) PARSE_OK && tok_type != TT_CRLF );
|
} while( status == ( parse_status_t ) PARSE_OK &&
|
||||||
|
tok_type != ( token_type_t ) TT_CRLF );
|
||||||
|
|
||||||
if( status == ( parse_status_t ) PARSE_OK ) {
|
if( status == ( parse_status_t ) PARSE_OK ) {
|
||||||
/* pushback crlf in stream */
|
/* pushback crlf in stream */
|
||||||
@ -973,8 +977,8 @@ static parse_status_t vfmatch(
|
|||||||
save_pos = scanner->cursor;
|
save_pos = scanner->cursor;
|
||||||
|
|
||||||
status = PARSE_OK;
|
status = PARSE_OK;
|
||||||
while( ( ( c = *fmt_ptr++ ) != 0 ) && ( status == PARSE_OK )
|
while( ( ( c = *fmt_ptr++ ) != 0 ) &&
|
||||||
) {
|
( status == ( parse_status_t ) PARSE_OK ) ) {
|
||||||
if( c == '%' ) {
|
if( c == '%' ) {
|
||||||
c = *fmt_ptr++;
|
c = *fmt_ptr++;
|
||||||
switch ( c ) {
|
switch ( c ) {
|
||||||
@ -989,7 +993,7 @@ static parse_status_t vfmatch(
|
|||||||
status = scanner_get_token( scanner, str_ptr,
|
status = scanner_get_token( scanner, str_ptr,
|
||||||
&tok_type );
|
&tok_type );
|
||||||
if( status == ( parse_status_t ) PARSE_OK &&
|
if( status == ( parse_status_t ) PARSE_OK &&
|
||||||
tok_type != TT_IDENTIFIER ) {
|
tok_type != ( token_type_t ) TT_IDENTIFIER ) {
|
||||||
/* not an identifier */
|
/* not an identifier */
|
||||||
status = PARSE_NO_MATCH;
|
status = PARSE_NO_MATCH;
|
||||||
}
|
}
|
||||||
@ -998,7 +1002,7 @@ static parse_status_t vfmatch(
|
|||||||
status = scanner_get_token( scanner,
|
status = scanner_get_token( scanner,
|
||||||
&token, &tok_type );
|
&token, &tok_type );
|
||||||
if( status == ( parse_status_t ) PARSE_OK &&
|
if( status == ( parse_status_t ) PARSE_OK &&
|
||||||
tok_type != TT_CRLF ) {
|
tok_type != ( token_type_t ) TT_CRLF ) {
|
||||||
/* not CRLF token */
|
/* not CRLF token */
|
||||||
status = PARSE_NO_MATCH;
|
status = PARSE_NO_MATCH;
|
||||||
}
|
}
|
||||||
@ -1019,7 +1023,7 @@ static parse_status_t vfmatch(
|
|||||||
}
|
}
|
||||||
assert( str_ptr != NULL );
|
assert( str_ptr != NULL );
|
||||||
status = match_non_ws_string( scanner, str_ptr );
|
status = match_non_ws_string( scanner, str_ptr );
|
||||||
if( c == 'U' && status == PARSE_OK ) {
|
if( c == 'U' && status == ( parse_status_t ) PARSE_OK ) {
|
||||||
uri_ptr = va_arg( argp, uri_type * );
|
uri_ptr = va_arg( argp, uri_type * );
|
||||||
assert( uri_ptr != NULL );
|
assert( uri_ptr != NULL );
|
||||||
stat = parse_uri( str_ptr->buf, str_ptr->length,
|
stat = parse_uri( str_ptr->buf, str_ptr->length,
|
||||||
@ -1049,7 +1053,7 @@ static parse_status_t vfmatch(
|
|||||||
status =
|
status =
|
||||||
scanner_get_token( scanner, str_ptr, &tok_type );
|
scanner_get_token( scanner, str_ptr, &tok_type );
|
||||||
if( status == ( parse_status_t ) PARSE_OK &&
|
if( status == ( parse_status_t ) PARSE_OK &&
|
||||||
tok_type != TT_QUOTEDSTRING ) {
|
tok_type != ( token_type_t ) TT_QUOTEDSTRING ) {
|
||||||
status = PARSE_NO_MATCH; /* not a quoted string */
|
status = PARSE_NO_MATCH; /* not a quoted string */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1058,7 +1062,7 @@ static parse_status_t vfmatch(
|
|||||||
status = scanner_get_token( scanner,
|
status = scanner_get_token( scanner,
|
||||||
&token, &tok_type );
|
&token, &tok_type );
|
||||||
if( status == ( parse_status_t ) PARSE_OK &&
|
if( status == ( parse_status_t ) PARSE_OK &&
|
||||||
tok_type != TT_WHITESPACE ) {
|
tok_type != ( token_type_t ) TT_WHITESPACE ) {
|
||||||
/* restore non-whitespace token */
|
/* restore non-whitespace token */
|
||||||
scanner->cursor -= token.length;
|
scanner->cursor -= token.length;
|
||||||
}
|
}
|
||||||
@ -1092,7 +1096,8 @@ static parse_status_t vfmatch(
|
|||||||
case '\t': /* Whitespace */
|
case '\t': /* Whitespace */
|
||||||
status = scanner_get_token( scanner,
|
status = scanner_get_token( scanner,
|
||||||
&token, &tok_type );
|
&token, &tok_type );
|
||||||
if( status == PARSE_OK && tok_type != TT_WHITESPACE ) {
|
if( status == ( parse_status_t ) PARSE_OK &&
|
||||||
|
tok_type != (token_type_t) TT_WHITESPACE ) {
|
||||||
/* not whitespace token */
|
/* not whitespace token */
|
||||||
status = PARSE_NO_MATCH;
|
status = PARSE_NO_MATCH;
|
||||||
}
|
}
|
||||||
@ -1104,7 +1109,7 @@ static parse_status_t vfmatch(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( status != PARSE_OK ) {
|
if( status != ( parse_status_t ) PARSE_OK ) {
|
||||||
/* on error, restore original scanner pos */
|
/* on error, restore original scanner pos */
|
||||||
scanner->cursor = save_pos;
|
scanner->cursor = save_pos;
|
||||||
}
|
}
|
||||||
@ -1409,7 +1414,7 @@ parse_status_t parser_parse_responseline(INOUT http_parser_t *parser)
|
|||||||
while (*p == ' ' || *p == '\t')
|
while (*p == ' ' || *p == '\t')
|
||||||
p++;
|
p++;
|
||||||
/* now, p is at start of status msg */
|
/* now, p is at start of status msg */
|
||||||
n = line.length - (size_t)(p - line.buf);
|
n = line.length - (size_t)p - (size_t)line.buf;
|
||||||
if (membuffer_assign(&hmsg->status_msg, p, n) != 0) {
|
if (membuffer_assign(&hmsg->status_msg, p, n) != 0) {
|
||||||
/* out of mem */
|
/* out of mem */
|
||||||
parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR;
|
parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR;
|
||||||
@ -1449,33 +1454,35 @@ parse_status_t parser_parse_headers(INOUT http_parser_t *parser)
|
|||||||
char save_char;
|
char save_char;
|
||||||
int ret2;
|
int ret2;
|
||||||
|
|
||||||
assert(parser->position == POS_HEADERS ||
|
assert(parser->position == (parser_pos_t)POS_HEADERS ||
|
||||||
parser->ent_position == ENTREAD_CHUNKY_HEADERS);
|
parser->ent_position == ENTREAD_CHUNKY_HEADERS);
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
save_pos = scanner->cursor;
|
save_pos = scanner->cursor;
|
||||||
/* check end of headers */
|
/* check end of headers */
|
||||||
status = scanner_get_token(scanner, &token, &tok_type);
|
status = scanner_get_token(scanner, &token, &tok_type);
|
||||||
if (status != PARSE_OK) {
|
if (status != (parse_status_t)PARSE_OK) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
if (tok_type == TT_CRLF) {
|
switch (tok_type) {
|
||||||
|
case TT_CRLF:
|
||||||
/* end of headers */
|
/* end of headers */
|
||||||
if ((parser->msg.is_request)
|
if ((parser->msg.is_request)
|
||||||
&& (parser->msg.method == HTTPMETHOD_POST)) {
|
&& (parser->msg.method == (http_method_t)HTTPMETHOD_POST)) {
|
||||||
parser->position = POS_COMPLETE; /*post entity parsing */
|
parser->position = POS_COMPLETE; /*post entity parsing */
|
||||||
/*is handled separately */
|
/*is handled separately */
|
||||||
return PARSE_SUCCESS;
|
return PARSE_SUCCESS;
|
||||||
}
|
}
|
||||||
parser->position = POS_ENTITY; /* read entity next */
|
parser->position = POS_ENTITY; /* read entity next */
|
||||||
return PARSE_OK;
|
return PARSE_OK;
|
||||||
}
|
case TT_IDENTIFIER:
|
||||||
/* not end; read header */
|
/* not end; read header */
|
||||||
if (tok_type != TT_IDENTIFIER) {
|
break;
|
||||||
|
default:
|
||||||
return PARSE_FAILURE; /* didn't see header name */
|
return PARSE_FAILURE; /* didn't see header name */
|
||||||
}
|
}
|
||||||
status = match(scanner, " : %R%c", &hdr_value);
|
status = match(scanner, " : %R%c", &hdr_value);
|
||||||
if (status != PARSE_OK) {
|
if (status != (parse_status_t)PARSE_OK) {
|
||||||
/* pushback tokens; useful only on INCOMPLETE error */
|
/* pushback tokens; useful only on INCOMPLETE error */
|
||||||
scanner->cursor = save_pos;
|
scanner->cursor = save_pos;
|
||||||
return status;
|
return status;
|
||||||
@ -1513,10 +1520,10 @@ parse_status_t parser_parse_headers(INOUT http_parser_t *parser)
|
|||||||
membuffer_init(&header->name_buf);
|
membuffer_init(&header->name_buf);
|
||||||
membuffer_init(&header->value);
|
membuffer_init(&header->value);
|
||||||
/* value can be 0 length */
|
/* value can be 0 length */
|
||||||
if (hdr_value.length == 0) {
|
if (hdr_value.length == (size_t)0) {
|
||||||
/* FIXME: Is this a bug? buf is not const. */
|
/* FIXME: Is this a bug? buf is not const. */
|
||||||
hdr_value.buf = "\0";
|
hdr_value.buf = "\0";
|
||||||
hdr_value.length = 1;
|
hdr_value.length = (size_t)1;
|
||||||
}
|
}
|
||||||
/* save in header in buffers */
|
/* save in header in buffers */
|
||||||
if (membuffer_assign(&header->name_buf, token.buf, token.length) ||
|
if (membuffer_assign(&header->name_buf, token.buf, token.length) ||
|
||||||
@ -1531,14 +1538,14 @@ parse_status_t parser_parse_headers(INOUT http_parser_t *parser)
|
|||||||
header->name_id = header_id;
|
header->name_id = header_id;
|
||||||
ListAddTail(&parser->msg.headers, header);
|
ListAddTail(&parser->msg.headers, header);
|
||||||
/*NNS: ret = dlist_append( &parser->msg.headers, header ); */
|
/*NNS: ret = dlist_append( &parser->msg.headers, header ); */
|
||||||
/** TODO: remove that? */
|
/** TODO: remove that? Yes as ret is not set anymore
|
||||||
if (ret == UPNP_E_OUTOF_MEMORY) {
|
if (ret == UPNP_E_OUTOF_MEMORY) {
|
||||||
parser->http_error_code =
|
parser->http_error_code =
|
||||||
HTTP_INTERNAL_SERVER_ERROR;
|
HTTP_INTERNAL_SERVER_ERROR;
|
||||||
return PARSE_FAILURE;
|
return PARSE_FAILURE;
|
||||||
}
|
}
|
||||||
/** end of remove that? */
|
end of remove that? */
|
||||||
} else if (hdr_value.length > 0) {
|
} else if (hdr_value.length > (size_t)0) {
|
||||||
/* append value to existing header */
|
/* append value to existing header */
|
||||||
/* append space */
|
/* append space */
|
||||||
ret = membuffer_append_str(&orig_header->value, ", ");
|
ret = membuffer_append_str(&orig_header->value, ", ");
|
||||||
@ -1626,13 +1633,13 @@ static UPNP_INLINE parse_status_t parser_parse_chunky_body(
|
|||||||
size_t save_pos;
|
size_t save_pos;
|
||||||
|
|
||||||
/* if 'chunk_size' of bytes have been read; read next chunk */
|
/* if 'chunk_size' of bytes have been read; read next chunk */
|
||||||
if ((int)(parser->msg.msg.length - parser->scanner.cursor) >= parser->chunk_size) {
|
if ((parser->msg.msg.length - parser->scanner.cursor) >= parser->chunk_size) {
|
||||||
/* move to next chunk */
|
/* move to next chunk */
|
||||||
parser->scanner.cursor += parser->chunk_size;
|
parser->scanner.cursor += parser->chunk_size;
|
||||||
save_pos = parser->scanner.cursor;
|
save_pos = parser->scanner.cursor;
|
||||||
/* discard CRLF */
|
/* discard CRLF */
|
||||||
status = match(&parser->scanner, "%c");
|
status = match(&parser->scanner, "%c");
|
||||||
if (status != PARSE_OK) {
|
if (status != (parse_status_t)PARSE_OK) {
|
||||||
/*move back */
|
/*move back */
|
||||||
parser->scanner.cursor -= parser->chunk_size;
|
parser->scanner.cursor -= parser->chunk_size;
|
||||||
/*parser->scanner.cursor = save_pos; */
|
/*parser->scanner.cursor = save_pos; */
|
||||||
@ -1671,7 +1678,7 @@ parser_parse_chunky_headers( INOUT http_parser_t * parser )
|
|||||||
|
|
||||||
save_pos = parser->scanner.cursor;
|
save_pos = parser->scanner.cursor;
|
||||||
status = parser_parse_headers( parser );
|
status = parser_parse_headers( parser );
|
||||||
if( status == PARSE_OK ) {
|
if( status == ( parse_status_t ) PARSE_OK ) {
|
||||||
/* finally, done with the whole msg */
|
/* finally, done with the whole msg */
|
||||||
parser->position = POS_COMPLETE;
|
parser->position = POS_COMPLETE;
|
||||||
|
|
||||||
@ -1717,7 +1724,7 @@ parser_parse_chunky_entity( INOUT http_parser_t * parser )
|
|||||||
|
|
||||||
/* get size of chunk, discard extension, discard CRLF */
|
/* get size of chunk, discard extension, discard CRLF */
|
||||||
status = match( scanner, "%x%L%c", &parser->chunk_size, &dummy );
|
status = match( scanner, "%x%L%c", &parser->chunk_size, &dummy );
|
||||||
if( status != PARSE_OK ) {
|
if( status != ( parse_status_t ) PARSE_OK ) {
|
||||||
scanner->cursor = save_pos;
|
scanner->cursor = save_pos;
|
||||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
"CHUNK COULD NOT BE PARSED\n" );
|
"CHUNK COULD NOT BE PARSED\n" );
|
||||||
@ -1801,7 +1808,7 @@ parser_get_entity_read_method( INOUT http_parser_t * parser )
|
|||||||
|
|
||||||
/* entity points to start of msg body */
|
/* entity points to start of msg body */
|
||||||
parser->msg.entity.buf = scanner_get_str( &parser->scanner );
|
parser->msg.entity.buf = scanner_get_str( &parser->scanner );
|
||||||
parser->msg.entity.length = 0;
|
parser->msg.entity.length = ( size_t ) 0;
|
||||||
|
|
||||||
/* remember start of body */
|
/* remember start of body */
|
||||||
parser->entity_start_position = parser->scanner.cursor;
|
parser->entity_start_position = parser->scanner.cursor;
|
||||||
@ -1833,11 +1840,11 @@ parser_get_entity_read_method( INOUT http_parser_t * parser )
|
|||||||
if( response_code == 204 ||
|
if( response_code == 204 ||
|
||||||
response_code == 304 ||
|
response_code == 304 ||
|
||||||
( response_code >= 100 && response_code <= 199 ) ||
|
( response_code >= 100 && response_code <= 199 ) ||
|
||||||
hmsg->request_method == HTTPMETHOD_HEAD ||
|
hmsg->request_method == ( http_method_t ) HTTPMETHOD_HEAD ||
|
||||||
hmsg->request_method == HTTPMETHOD_MSEARCH ||
|
hmsg->request_method == ( http_method_t ) HTTPMETHOD_MSEARCH ||
|
||||||
hmsg->request_method == HTTPMETHOD_SUBSCRIBE ||
|
hmsg->request_method == ( http_method_t ) HTTPMETHOD_SUBSCRIBE ||
|
||||||
hmsg->request_method == HTTPMETHOD_UNSUBSCRIBE ||
|
hmsg->request_method == ( http_method_t ) HTTPMETHOD_UNSUBSCRIBE ||
|
||||||
hmsg->request_method == HTTPMETHOD_NOTIFY ) {
|
hmsg->request_method == ( http_method_t ) HTTPMETHOD_NOTIFY ) {
|
||||||
parser->position = POS_COMPLETE;
|
parser->position = POS_COMPLETE;
|
||||||
return PARSE_SUCCESS;
|
return PARSE_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -1866,7 +1873,7 @@ parser_get_entity_read_method( INOUT http_parser_t * parser )
|
|||||||
if( hmsg->is_request ) {
|
if( hmsg->is_request ) {
|
||||||
/* set hack flag for NOTIFY methods; if set to true this is */
|
/* set hack flag for NOTIFY methods; if set to true this is */
|
||||||
/* a valid SSDP notify msg */
|
/* a valid SSDP notify msg */
|
||||||
if( hmsg->method == HTTPMETHOD_NOTIFY ) {
|
if( hmsg->method == ( http_method_t ) HTTPMETHOD_NOTIFY ) {
|
||||||
parser->valid_ssdp_notify_hack = TRUE;
|
parser->valid_ssdp_notify_hack = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1928,7 +1935,7 @@ parser_parse_entity( INOUT http_parser_t * parser )
|
|||||||
assert( 0 );
|
assert( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
} while( status == PARSE_CONTINUE_1 );
|
} while( status == ( parse_status_t ) PARSE_CONTINUE_1 );
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -1971,7 +1978,7 @@ parser_response_init( OUT http_parser_t * parser,
|
|||||||
parser_init( parser );
|
parser_init( parser );
|
||||||
parser->msg.is_request = FALSE;
|
parser->msg.is_request = FALSE;
|
||||||
parser->msg.request_method = request_method;
|
parser->msg.request_method = request_method;
|
||||||
parser->msg.amount_discarded = 0;
|
parser->msg.amount_discarded = (size_t)0;
|
||||||
parser->position = POS_RESPONSE_LINE;
|
parser->position = POS_RESPONSE_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2025,7 +2032,7 @@ parser_parse( INOUT http_parser_t * parser )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} while( status == PARSE_OK );
|
} while( status == ( parse_status_t ) PARSE_OK );
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
@ -2084,7 +2091,7 @@ int raw_to_int(IN memptr *raw_value, IN int base)
|
|||||||
long num;
|
long num;
|
||||||
char *end_ptr;
|
char *end_ptr;
|
||||||
|
|
||||||
if (raw_value->length == 0)
|
if (raw_value->length == (size_t)0)
|
||||||
return -1;
|
return -1;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
num = strtol(raw_value->buf, &end_ptr, base);
|
num = strtol(raw_value->buf, &end_ptr, base);
|
||||||
|
@ -172,13 +172,13 @@ int http_FixUrl(IN uri_type *url, OUT uri_type *fixed_url)
|
|||||||
if (token_string_casecmp(&fixed_url->scheme, "http") != 0) {
|
if (token_string_casecmp(&fixed_url->scheme, "http") != 0) {
|
||||||
return UPNP_E_INVALID_URL;
|
return UPNP_E_INVALID_URL;
|
||||||
}
|
}
|
||||||
if( fixed_url->hostport.text.size == 0 ) {
|
if( fixed_url->hostport.text.size == ( size_t ) 0 ) {
|
||||||
return UPNP_E_INVALID_URL;
|
return UPNP_E_INVALID_URL;
|
||||||
}
|
}
|
||||||
/* set pathquery to "/" if it is empty */
|
/* set pathquery to "/" if it is empty */
|
||||||
if (fixed_url->pathquery.size == 0) {
|
if (fixed_url->pathquery.size == (size_t)0) {
|
||||||
fixed_url->pathquery.buff = temp_path;
|
fixed_url->pathquery.buff = temp_path;
|
||||||
fixed_url->pathquery.size = 1;
|
fixed_url->pathquery.size = (size_t)1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
@ -223,7 +223,8 @@ SOCKET http_Connect(
|
|||||||
|
|
||||||
http_FixUrl(destination_url, url);
|
http_FixUrl(destination_url, url);
|
||||||
|
|
||||||
connfd = socket(url->hostport.IPaddress.ss_family, SOCK_STREAM, 0);
|
connfd = socket((int)url->hostport.IPaddress.ss_family,
|
||||||
|
SOCK_STREAM, 0);
|
||||||
if (connfd == INVALID_SOCKET) {
|
if (connfd == INVALID_SOCKET) {
|
||||||
return (SOCKET)(UPNP_E_OUTOF_SOCKET);
|
return (SOCKET)(UPNP_E_OUTOF_SOCKET);
|
||||||
}
|
}
|
||||||
@ -639,7 +640,7 @@ int http_Download( IN const char *url_str,
|
|||||||
memptr ctype;
|
memptr ctype;
|
||||||
size_t copy_len;
|
size_t copy_len;
|
||||||
membuffer request;
|
membuffer request;
|
||||||
char *urlPath = alloca(strlen(url_str) + 1);
|
char *urlPath = alloca(strlen(url_str) + (size_t)1);
|
||||||
|
|
||||||
/*ret_code = parse_uri( (char*)url_str, strlen(url_str), &url ); */
|
/*ret_code = parse_uri( (char*)url_str, strlen(url_str), &url ); */
|
||||||
UpnpPrintf(UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
@ -649,7 +650,7 @@ int http_Download( IN const char *url_str,
|
|||||||
return ret_code;
|
return ret_code;
|
||||||
/* make msg */
|
/* make msg */
|
||||||
membuffer_init(&request);
|
membuffer_init(&request);
|
||||||
memset(urlPath, 0, strlen(url_str) + 1);
|
memset(urlPath, 0, strlen(url_str) + (size_t)1);
|
||||||
strncpy(urlPath, url_str, strlen(url_str));
|
strncpy(urlPath, url_str, strlen(url_str));
|
||||||
hoststr = strstr(urlPath, "//");
|
hoststr = strstr(urlPath, "//");
|
||||||
if (hoststr == NULL)
|
if (hoststr == NULL)
|
||||||
@ -697,15 +698,15 @@ int http_Download( IN const char *url_str,
|
|||||||
*content_type = '\0'; /* no content-type */
|
*content_type = '\0'; /* no content-type */
|
||||||
} else {
|
} else {
|
||||||
/* safety */
|
/* safety */
|
||||||
copy_len = ctype.length < LINE_SIZE - 1 ?
|
copy_len = ctype.length < LINE_SIZE - (size_t)1 ?
|
||||||
ctype.length : LINE_SIZE - 1;
|
ctype.length : LINE_SIZE - (size_t)1;
|
||||||
|
|
||||||
memcpy(content_type, ctype.buf, copy_len);
|
memcpy(content_type, ctype.buf, copy_len);
|
||||||
content_type[copy_len] = '\0';
|
content_type[copy_len] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* extract doc from msg */
|
/* extract doc from msg */
|
||||||
if ((*doc_length = response.msg.entity.length) == 0) {
|
if ((*doc_length = response.msg.entity.length) == (size_t)0) {
|
||||||
/* 0-length msg */
|
/* 0-length msg */
|
||||||
*document = NULL;
|
*document = NULL;
|
||||||
} else if (response.msg.status_code == HTTP_OK) {
|
} else if (response.msg.status_code == HTTP_OK) {
|
||||||
@ -715,9 +716,9 @@ int http_Download( IN const char *url_str,
|
|||||||
msg_length = response.msg.msg.length; /* save for posterity */
|
msg_length = response.msg.msg.length; /* save for posterity */
|
||||||
msg_start = membuffer_detach(&response.msg.msg); /* whole msg */
|
msg_start = membuffer_detach(&response.msg.msg); /* whole msg */
|
||||||
/* move entity to the start; copy null-terminator too */
|
/* move entity to the start; copy null-terminator too */
|
||||||
memmove(msg_start, entity_start, *doc_length + 1);
|
memmove(msg_start, entity_start, *doc_length + (size_t)1);
|
||||||
/* save mem for body only */
|
/* save mem for body only */
|
||||||
*document = realloc(msg_start, *doc_length + 1); /*LEAK_FIX_MK */
|
*document = realloc(msg_start, *doc_length + (size_t)1); /*LEAK_FIX_MK */
|
||||||
/* *document = Realloc( msg_start,msg_length, *doc_length + 1 ); LEAK_FIX_MK */
|
/* *document = Realloc( msg_start,msg_length, *doc_length + 1 ); LEAK_FIX_MK */
|
||||||
/* shrink can't fail */
|
/* shrink can't fail */
|
||||||
assert(msg_length > *doc_length);
|
assert(msg_length > *doc_length);
|
||||||
@ -763,8 +764,8 @@ int MakePostMessage(const char *url_str, membuffer *request,
|
|||||||
uri_type *url, int contentLength, const char *contentType)
|
uri_type *url, int contentLength, const char *contentType)
|
||||||
{
|
{
|
||||||
int ret_code = 0;
|
int ret_code = 0;
|
||||||
char *urlPath = alloca(strlen(url_str) + 1);
|
char *urlPath = alloca(strlen(url_str) + (size_t)1);
|
||||||
size_t hostlen = 0;
|
size_t hostlen = (size_t)0;
|
||||||
char *hoststr;
|
char *hoststr;
|
||||||
char *temp;
|
char *temp;
|
||||||
|
|
||||||
@ -775,7 +776,7 @@ int MakePostMessage(const char *url_str, membuffer *request,
|
|||||||
return ret_code;
|
return ret_code;
|
||||||
/* make msg */
|
/* make msg */
|
||||||
membuffer_init(request);
|
membuffer_init(request);
|
||||||
memset(urlPath, 0, strlen(url_str) + 1);
|
memset(urlPath, 0, strlen(url_str) + (size_t)1);
|
||||||
strncpy(urlPath, url_str, strlen(url_str));
|
strncpy(urlPath, url_str, strlen(url_str));
|
||||||
hoststr = strstr(urlPath, "//");
|
hoststr = strstr(urlPath, "//");
|
||||||
if (hoststr == NULL)
|
if (hoststr == NULL)
|
||||||
@ -1049,10 +1050,10 @@ int MakeGetMessage(const char *url_str, const char *proxy_str,
|
|||||||
membuffer *request, uri_type *url)
|
membuffer *request, uri_type *url)
|
||||||
{
|
{
|
||||||
int ret_code;
|
int ret_code;
|
||||||
char *urlPath = alloca(strlen(url_str) + 1);
|
char *urlPath = alloca(strlen(url_str) + (size_t)1);
|
||||||
size_t querylen = 0;
|
size_t querylen = (size_t)0;
|
||||||
const char *querystr;
|
const char *querystr;
|
||||||
size_t hostlen = 0;
|
size_t hostlen = (size_t)0;
|
||||||
char *hoststr, *temp;
|
char *hoststr, *temp;
|
||||||
|
|
||||||
UpnpPrintf(UPNP_INFO, HTTP, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
@ -1062,7 +1063,7 @@ int MakeGetMessage(const char *url_str, const char *proxy_str,
|
|||||||
return ret_code;
|
return ret_code;
|
||||||
/* make msg */
|
/* make msg */
|
||||||
membuffer_init(request);
|
membuffer_init(request);
|
||||||
memset(urlPath, 0, strlen(url_str) + 1);
|
memset(urlPath, 0, strlen(url_str) + (size_t)1);
|
||||||
strncpy(urlPath, url_str, strlen(url_str));
|
strncpy(urlPath, url_str, strlen(url_str));
|
||||||
hoststr = strstr(urlPath, "//");
|
hoststr = strstr(urlPath, "//");
|
||||||
if (hoststr == NULL)
|
if (hoststr == NULL)
|
||||||
@ -1129,13 +1130,17 @@ static parse_status_t ReadResponseLineAndHeaders(
|
|||||||
|
|
||||||
/*read response line */
|
/*read response line */
|
||||||
status = parser_parse_responseline(parser);
|
status = parser_parse_responseline(parser);
|
||||||
if (status == PARSE_OK)
|
switch (status) {
|
||||||
|
case PARSE_OK:
|
||||||
done = 1;
|
done = 1;
|
||||||
else if (status == PARSE_INCOMPLETE)
|
break;
|
||||||
|
case PARSE_INCOMPLETE:
|
||||||
done = 0;
|
done = 0;
|
||||||
else
|
break;
|
||||||
|
default:
|
||||||
/*error */
|
/*error */
|
||||||
return status;
|
return status;
|
||||||
|
}
|
||||||
while (!done) {
|
while (!done) {
|
||||||
num_read = sock_read(info, buf, sizeof(buf), timeout_secs);
|
num_read = sock_read(info, buf, sizeof(buf), timeout_secs);
|
||||||
if (num_read > 0) {
|
if (num_read > 0) {
|
||||||
@ -1149,11 +1154,14 @@ static parse_status_t ReadResponseLineAndHeaders(
|
|||||||
return PARSE_FAILURE;
|
return PARSE_FAILURE;
|
||||||
}
|
}
|
||||||
status = parser_parse_responseline(parser);
|
status = parser_parse_responseline(parser);
|
||||||
if (status == PARSE_OK) {
|
switch (status) {
|
||||||
|
case PARSE_OK:
|
||||||
done = 1;
|
done = 1;
|
||||||
} else if (status == PARSE_INCOMPLETE) {
|
break;
|
||||||
|
case PARSE_INCOMPLETE:
|
||||||
done = 0;
|
done = 0;
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
/*error */
|
/*error */
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -1168,9 +1176,10 @@ static parse_status_t ReadResponseLineAndHeaders(
|
|||||||
}
|
}
|
||||||
done = 0;
|
done = 0;
|
||||||
status = parser_parse_headers(parser);
|
status = parser_parse_headers(parser);
|
||||||
if ((status == PARSE_OK) && (parser->position == POS_ENTITY))
|
if ((status == (parse_status_t)PARSE_OK) &&
|
||||||
|
(parser->position == (parser_pos_t)POS_ENTITY))
|
||||||
done = 1;
|
done = 1;
|
||||||
else if (status == PARSE_INCOMPLETE)
|
else if (status == (parse_status_t)PARSE_INCOMPLETE)
|
||||||
done = 0;
|
done = 0;
|
||||||
else
|
else
|
||||||
/*error */
|
/*error */
|
||||||
@ -1188,9 +1197,10 @@ static parse_status_t ReadResponseLineAndHeaders(
|
|||||||
return PARSE_FAILURE;
|
return PARSE_FAILURE;
|
||||||
}
|
}
|
||||||
status = parser_parse_headers(parser);
|
status = parser_parse_headers(parser);
|
||||||
if (status == PARSE_OK && parser->position == POS_ENTITY)
|
if (status == (parse_status_t)PARSE_OK &&
|
||||||
|
parser->position == (parser_pos_t)POS_ENTITY)
|
||||||
done = 1;
|
done = 1;
|
||||||
else if (status == PARSE_INCOMPLETE)
|
else if (status == (parse_status_t)PARSE_INCOMPLETE)
|
||||||
done = 0;
|
done = 0;
|
||||||
else
|
else
|
||||||
/*error */
|
/*error */
|
||||||
@ -1473,7 +1483,7 @@ int http_OpenHttpGetProxy(const char *url_str, const char *proxy_str,
|
|||||||
handle->cancel = 0;
|
handle->cancel = 0;
|
||||||
parser_response_init(&handle->response, HTTPMETHOD_GET);
|
parser_response_init(&handle->response, HTTPMETHOD_GET);
|
||||||
tcp_connection =
|
tcp_connection =
|
||||||
socket(peer->hostport.IPaddress.ss_family, SOCK_STREAM, 0);
|
socket((int)peer->hostport.IPaddress.ss_family, SOCK_STREAM, 0);
|
||||||
if (tcp_connection == INVALID_SOCKET) {
|
if (tcp_connection == INVALID_SOCKET) {
|
||||||
ret_code = UPNP_E_SOCKET_ERROR;
|
ret_code = UPNP_E_SOCKET_ERROR;
|
||||||
goto errorHandler;
|
goto errorHandler;
|
||||||
@ -1651,7 +1661,7 @@ int http_MakeMessage(membuffer *buf, int http_major_version,
|
|||||||
goto error_handler;
|
goto error_handler;
|
||||||
} else if (c == 'c') {
|
} else if (c == 'c') {
|
||||||
/* crlf */
|
/* crlf */
|
||||||
if (membuffer_append(buf, "\r\n", 2))
|
if (membuffer_append(buf, "\r\n", (size_t)2))
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
} else if (c == 'd') {
|
} else if (c == 'd') {
|
||||||
/* integer */
|
/* integer */
|
||||||
@ -1873,7 +1883,7 @@ int MakeGetMessageEx( const char *url_str,
|
|||||||
{
|
{
|
||||||
int errCode = UPNP_E_SUCCESS;
|
int errCode = UPNP_E_SUCCESS;
|
||||||
char *urlPath = NULL;
|
char *urlPath = NULL;
|
||||||
size_t hostlen = 0;
|
size_t hostlen = (size_t)0;
|
||||||
char *hoststr, *temp;
|
char *hoststr, *temp;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -1886,12 +1896,12 @@ int MakeGetMessageEx( const char *url_str,
|
|||||||
}
|
}
|
||||||
/* make msg */
|
/* make msg */
|
||||||
membuffer_init(request);
|
membuffer_init(request);
|
||||||
urlPath = alloca(strlen(url_str) + 1);
|
urlPath = alloca(strlen(url_str) + (size_t)1);
|
||||||
if (!urlPath) {
|
if (!urlPath) {
|
||||||
errCode = UPNP_E_OUTOF_MEMORY;
|
errCode = UPNP_E_OUTOF_MEMORY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
memset(urlPath, 0, strlen(url_str) + 1);
|
memset(urlPath, 0, strlen(url_str) + (size_t)1);
|
||||||
strncpy(urlPath, url_str, strlen(url_str));
|
strncpy(urlPath, url_str, strlen(url_str));
|
||||||
hoststr = strstr(urlPath, "//");
|
hoststr = strstr(urlPath, "//");
|
||||||
if (hoststr == NULL) {
|
if (hoststr == NULL) {
|
||||||
@ -2012,7 +2022,8 @@ int http_OpenHttpGetEx(
|
|||||||
}
|
}
|
||||||
memset(handle, 0, sizeof(*handle));
|
memset(handle, 0, sizeof(*handle));
|
||||||
parser_response_init(&handle->response, HTTPMETHOD_GET);
|
parser_response_init(&handle->response, HTTPMETHOD_GET);
|
||||||
tcp_connection = socket(url.hostport.IPaddress.ss_family, SOCK_STREAM, 0);
|
tcp_connection = socket((int)url.hostport.IPaddress.ss_family,
|
||||||
|
SOCK_STREAM, 0);
|
||||||
if (tcp_connection == INVALID_SOCKET) {
|
if (tcp_connection == INVALID_SOCKET) {
|
||||||
errCode = UPNP_E_SOCKET_ERROR;
|
errCode = UPNP_E_SOCKET_ERROR;
|
||||||
free(handle);
|
free(handle);
|
||||||
@ -2065,7 +2076,7 @@ int http_OpenHttpGetEx(
|
|||||||
*contentType = NULL;
|
*contentType = NULL;
|
||||||
else
|
else
|
||||||
*contentType = ctype.buf;
|
*contentType = ctype.buf;
|
||||||
if (handle->response.position == POS_COMPLETE)
|
if (handle->response.position == (parser_pos_t)POS_COMPLETE)
|
||||||
*contentLength = 0;
|
*contentLength = 0;
|
||||||
else if(handle->response.ent_position == ENTREAD_USING_CHUNKED)
|
else if(handle->response.ent_position == ENTREAD_USING_CHUNKED)
|
||||||
*contentLength = UPNP_USING_CHUNKED;
|
*contentLength = UPNP_USING_CHUNKED;
|
||||||
|
@ -126,7 +126,7 @@
|
|||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define THREAD_STACK_SIZE 0
|
#define THREAD_STACK_SIZE (size_t)0
|
||||||
/* @} */
|
/* @} */
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ typedef struct {
|
|||||||
parser_pos_t position;
|
parser_pos_t position;
|
||||||
int ent_position;
|
int ent_position;
|
||||||
unsigned int content_length;
|
unsigned int content_length;
|
||||||
int chunk_size;
|
size_t chunk_size;
|
||||||
/*! offset in the the raw message buffer, which contains the message body.
|
/*! offset in the the raw message buffer, which contains the message body.
|
||||||
* preceding this are the headers of the messsage. */
|
* preceding this are the headers of the messsage. */
|
||||||
size_t entity_start_position;
|
size_t entity_start_position;
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
#define DEFAULT_MAXAGE 1800
|
#define DEFAULT_MAXAGE 1800
|
||||||
|
|
||||||
#define DEFAULT_SOAP_CONTENT_LENGTH 16000
|
#define DEFAULT_SOAP_CONTENT_LENGTH 16000
|
||||||
#define MAX_SOAP_CONTENT_LENGTH 32000
|
#define MAX_SOAP_CONTENT_LENGTH (size_t)32000
|
||||||
|
|
||||||
extern size_t g_maxContentLength;
|
extern size_t g_maxContentLength;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user