mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-04 09:44:26 +00:00
[xmlrpc-c] Coverity 1024180, 1024205, 1024301, 1024847, 1024848, 1024377, 1024378, 1024379, 1024380, 1024381, 1024584, 1024495, 1214208 fixes.
This commit is contained in:
parent
ca0f58f565
commit
dd299d9bab
@ -305,7 +305,7 @@ sendDirectoryDocument(TList * const listP,
|
|||||||
if (k > 24) {
|
if (k > 24) {
|
||||||
snprintf(z1, sizeof(z1), "%.10s...%s", z, z + k - 11);
|
snprintf(z1, sizeof(z1), "%.10s...%s", z, z + k - 11);
|
||||||
k = 24;
|
k = 24;
|
||||||
p = z1 + 24;
|
p = z1 + k;
|
||||||
} else {
|
} else {
|
||||||
snprintf(z1, sizeof(z1), "%s", z);
|
snprintf(z1, sizeof(z1), "%s", z);
|
||||||
|
|
||||||
|
@ -2416,6 +2416,7 @@ doStartTagNoAtts(XML_Parser const xmlParserP,
|
|||||||
}
|
}
|
||||||
tag->buf = malloc(INIT_TAG_BUF_SIZE);
|
tag->buf = malloc(INIT_TAG_BUF_SIZE);
|
||||||
if (!tag->buf) {
|
if (!tag->buf) {
|
||||||
|
free(tag);
|
||||||
*errorCodeP = XML_ERROR_NO_MEMORY;
|
*errorCodeP = XML_ERROR_NO_MEMORY;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3646,8 +3647,10 @@ doProlog(XML_Parser const xmlParserP,
|
|||||||
switch (tok) {
|
switch (tok) {
|
||||||
case XML_TOK_PARAM_ENTITY_REF:
|
case XML_TOK_PARAM_ENTITY_REF:
|
||||||
*errorCodeP = XML_ERROR_PARAM_ENTITY_REF;
|
*errorCodeP = XML_ERROR_PARAM_ENTITY_REF;
|
||||||
|
break;
|
||||||
case XML_TOK_XML_DECL:
|
case XML_TOK_XML_DECL:
|
||||||
*errorCodeP = XML_ERROR_MISPLACED_XML_PI;
|
*errorCodeP = XML_ERROR_MISPLACED_XML_PI;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
*errorCodeP = XML_ERROR_SYNTAX;
|
*errorCodeP = XML_ERROR_SYNTAX;
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ decodeMultibyte(xmlrpc_env * const envP,
|
|||||||
|
|
||||||
Return the character in UTF-16 format as *wcP.
|
Return the character in UTF-16 format as *wcP.
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
wchar_t wc;
|
wchar_t wc = 0;
|
||||||
|
|
||||||
assert(utf8_seq[0] & 0x80); /* High bit set: this is multibyte seq */
|
assert(utf8_seq[0] & 0x80); /* High bit set: this is multibyte seq */
|
||||||
|
|
||||||
|
@ -181,9 +181,10 @@ releaseDecompArray(struct arrayDecomp const arrayDecomp,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
releaseDecompStruct(struct structDecomp const structDecomp,
|
releaseDecompStruct(struct structDecomp const *_structDecomp,
|
||||||
bool const oldstyleMemMgmt) {
|
bool const oldstyleMemMgmt) {
|
||||||
|
|
||||||
|
struct structDecomp const structDecomp = *_structDecomp;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for (i = 0; i < structDecomp.mbrCnt; ++i) {
|
for (i = 0; i < structDecomp.mbrCnt; ++i) {
|
||||||
releaseDecomposition(structDecomp.mbrArray[i].decompTreeP,
|
releaseDecomposition(structDecomp.mbrArray[i].decompTreeP,
|
||||||
@ -239,7 +240,7 @@ releaseDecomposition(const struct decompTreeNode * const decompRootP,
|
|||||||
releaseDecompArray(decompRootP->store.Tarray, oldstyleMemMgmt);
|
releaseDecompArray(decompRootP->store.Tarray, oldstyleMemMgmt);
|
||||||
break;
|
break;
|
||||||
case '{':
|
case '{':
|
||||||
releaseDecompStruct(decompRootP->store.Tstruct, oldstyleMemMgmt);
|
releaseDecompStruct(&decompRootP->store.Tstruct, oldstyleMemMgmt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -259,8 +260,9 @@ decomposeValueWithTree(xmlrpc_env * const envP,
|
|||||||
static void
|
static void
|
||||||
validateArraySize(xmlrpc_env * const envP,
|
validateArraySize(xmlrpc_env * const envP,
|
||||||
const xmlrpc_value * const arrayP,
|
const xmlrpc_value * const arrayP,
|
||||||
struct arrayDecomp const arrayDecomp) {
|
struct arrayDecomp const *_arrayDecomp) {
|
||||||
|
|
||||||
|
struct arrayDecomp const arrayDecomp = *_arrayDecomp;
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
|
|
||||||
size = xmlrpc_array_size(envP, arrayP);
|
size = xmlrpc_array_size(envP, arrayP);
|
||||||
@ -284,10 +286,12 @@ validateArraySize(xmlrpc_env * const envP,
|
|||||||
static void
|
static void
|
||||||
parsearray(xmlrpc_env * const envP,
|
parsearray(xmlrpc_env * const envP,
|
||||||
const xmlrpc_value * const arrayP,
|
const xmlrpc_value * const arrayP,
|
||||||
struct arrayDecomp const arrayDecomp,
|
struct arrayDecomp const *_arrayDecomp,
|
||||||
bool const oldstyleMemMgmt) {
|
bool const oldstyleMemMgmt) {
|
||||||
|
|
||||||
validateArraySize(envP, arrayP, arrayDecomp);
|
struct arrayDecomp const arrayDecomp = *_arrayDecomp;
|
||||||
|
|
||||||
|
validateArraySize(envP, arrayP, &arrayDecomp);
|
||||||
|
|
||||||
if (!envP->fault_occurred) {
|
if (!envP->fault_occurred) {
|
||||||
unsigned int doneCnt;
|
unsigned int doneCnt;
|
||||||
@ -324,9 +328,10 @@ parsearray(xmlrpc_env * const envP,
|
|||||||
static void
|
static void
|
||||||
parsestruct(xmlrpc_env * const envP,
|
parsestruct(xmlrpc_env * const envP,
|
||||||
xmlrpc_value * const structP,
|
xmlrpc_value * const structP,
|
||||||
struct structDecomp const structDecomp,
|
struct structDecomp const *_structDecomp,
|
||||||
bool const oldstyleMemMgmt) {
|
bool const oldstyleMemMgmt) {
|
||||||
|
|
||||||
|
struct structDecomp const structDecomp = *_structDecomp;
|
||||||
unsigned int doneCount;
|
unsigned int doneCount;
|
||||||
|
|
||||||
doneCount = 0; /* No members done yet */
|
doneCount = 0; /* No members done yet */
|
||||||
@ -569,7 +574,7 @@ decomposeValueWithTree(xmlrpc_env * const envP,
|
|||||||
"%s, but the '(...)' specifier requires type ARRAY",
|
"%s, but the '(...)' specifier requires type ARRAY",
|
||||||
xmlrpc_type_name(xmlrpc_value_type(valueP)));
|
xmlrpc_type_name(xmlrpc_value_type(valueP)));
|
||||||
else
|
else
|
||||||
parsearray(envP, valueP, decompRootP->store.Tarray,
|
parsearray(envP, valueP, &decompRootP->store.Tarray,
|
||||||
oldstyleMemMgmt);
|
oldstyleMemMgmt);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -580,7 +585,7 @@ decomposeValueWithTree(xmlrpc_env * const envP,
|
|||||||
"%s, but the '{...}' specifier requires type STRUCT",
|
"%s, but the '{...}' specifier requires type STRUCT",
|
||||||
xmlrpc_type_name(xmlrpc_value_type(valueP)));
|
xmlrpc_type_name(xmlrpc_value_type(valueP)));
|
||||||
else
|
else
|
||||||
parsestruct(envP, valueP, decompRootP->store.Tstruct,
|
parsestruct(envP, valueP, &decompRootP->store.Tstruct,
|
||||||
oldstyleMemMgmt);
|
oldstyleMemMgmt);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -179,9 +179,11 @@ sendResponse(xmlrpc_env * const envP,
|
|||||||
|
|
||||||
ResponseStatus(abyssSessionP, 200);
|
ResponseStatus(abyssSessionP, 200);
|
||||||
|
|
||||||
|
#if 0 /* Uncomment once http_cookie is not NULL again */
|
||||||
if (http_cookie)
|
if (http_cookie)
|
||||||
/* There's an auth cookie, so pass it back in the response. */
|
/* There's an auth cookie, so pass it back in the response. */
|
||||||
addAuthCookie(envP, abyssSessionP, http_cookie);
|
addAuthCookie(envP, abyssSessionP, http_cookie);
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((size_t)(uint32_t)len != len)
|
if ((size_t)(uint32_t)len != len)
|
||||||
xmlrpc_faultf(envP, "XML-RPC method generated a response too "
|
xmlrpc_faultf(envP, "XML-RPC method generated a response too "
|
||||||
|
@ -189,6 +189,7 @@ xmlrpc_server_cgi_process_call(xmlrpc_registry * const registryP) {
|
|||||||
size_t input_size, output_size;
|
size_t input_size, output_size;
|
||||||
int code;
|
int code;
|
||||||
char *message;
|
char *message;
|
||||||
|
char *err = NULL;
|
||||||
|
|
||||||
/* Error-handling preconditions. */
|
/* Error-handling preconditions. */
|
||||||
xmlrpc_env_init(&env);
|
xmlrpc_env_init(&env);
|
||||||
@ -209,13 +210,13 @@ xmlrpc_server_cgi_process_call(xmlrpc_registry * const registryP) {
|
|||||||
}
|
}
|
||||||
if (!type || !xmlrpc_strneq(type, "text/xml", strlen("text/xml"))) {
|
if (!type || !xmlrpc_strneq(type, "text/xml", strlen("text/xml"))) {
|
||||||
char *template = "Expected content type: \"text/xml\", received: \"%s\"";
|
char *template = "Expected content type: \"text/xml\", received: \"%s\"";
|
||||||
size_t err_len = strlen(template) + strlen(type) + 1;
|
size_t err_len = strlen(template) + (type ? strlen(type) : 0) + 1;
|
||||||
char *err = malloc(err_len);
|
|
||||||
|
|
||||||
(void)snprintf(err, err_len, template, type);
|
err = malloc(err_len);
|
||||||
|
|
||||||
|
(void)snprintf(err, err_len, template, (type ? type : ""));
|
||||||
code = 400; message = "Bad Request";
|
code = 400; message = "Bad Request";
|
||||||
XMLRPC_FAIL(&env, XMLRPC_INTERNAL_ERROR, err);
|
XMLRPC_FAIL(&env, XMLRPC_INTERNAL_ERROR, err);
|
||||||
free(err);
|
|
||||||
}
|
}
|
||||||
if (!length_str) {
|
if (!length_str) {
|
||||||
code = 411; message = "Length Required";
|
code = 411; message = "Length Required";
|
||||||
@ -254,6 +255,8 @@ xmlrpc_server_cgi_process_call(xmlrpc_registry * const registryP) {
|
|||||||
send_xml(output_data, output_size);
|
send_xml(output_data, output_size);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
if (err)
|
||||||
|
free(err);
|
||||||
if (input)
|
if (input)
|
||||||
xmlrpc_mem_block_free(input);
|
xmlrpc_mem_block_free(input);
|
||||||
if (output)
|
if (output)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user