Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[xmlrpc-c] Coverity 1024180, 1024205, 1024301, 1024847, 1024848, 1024377, 1024378, 1024379, 1024380, 1024381, 1024584, 1024495, 1214208 fixes. #2754

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/xmlrpc-c/lib/abyss/src/handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ sendDirectoryDocument(TList * const listP,
if (k > 24) {
snprintf(z1, sizeof(z1), "%.10s...%s", z, z + k - 11);
k = 24;
p = z1 + 24;
p = z1 + k;
} else {
snprintf(z1, sizeof(z1), "%s", z);

Expand Down
3 changes: 3 additions & 0 deletions libs/xmlrpc-c/lib/expat/xmlparse/xmlparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -2416,6 +2416,7 @@ doStartTagNoAtts(XML_Parser const xmlParserP,
}
tag->buf = malloc(INIT_TAG_BUF_SIZE);
if (!tag->buf) {
free(tag);
*errorCodeP = XML_ERROR_NO_MEMORY;
return;
}
Expand Down Expand Up @@ -3646,8 +3647,10 @@ doProlog(XML_Parser const xmlParserP,
switch (tok) {
case XML_TOK_PARAM_ENTITY_REF:
*errorCodeP = XML_ERROR_PARAM_ENTITY_REF;
break;
case XML_TOK_XML_DECL:
*errorCodeP = XML_ERROR_MISPLACED_XML_PI;
break;
default:
*errorCodeP = XML_ERROR_SYNTAX;
}
Expand Down
2 changes: 1 addition & 1 deletion libs/xmlrpc-c/lib/libutil/utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ decodeMultibyte(xmlrpc_env * const envP,
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 */

Expand Down
21 changes: 13 additions & 8 deletions libs/xmlrpc-c/src/xmlrpc_decompose.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@ releaseDecompArray(struct arrayDecomp const arrayDecomp,


static void
releaseDecompStruct(struct structDecomp const structDecomp,
releaseDecompStruct(struct structDecomp const *_structDecomp,
bool const oldstyleMemMgmt) {

struct structDecomp const structDecomp = *_structDecomp;
unsigned int i;
for (i = 0; i < structDecomp.mbrCnt; ++i) {
releaseDecomposition(structDecomp.mbrArray[i].decompTreeP,
Expand Down Expand Up @@ -239,7 +240,7 @@ releaseDecomposition(const struct decompTreeNode * const decompRootP,
releaseDecompArray(decompRootP->store.Tarray, oldstyleMemMgmt);
break;
case '{':
releaseDecompStruct(decompRootP->store.Tstruct, oldstyleMemMgmt);
releaseDecompStruct(&decompRootP->store.Tstruct, oldstyleMemMgmt);
break;
}
}
Expand All @@ -259,8 +260,9 @@ decomposeValueWithTree(xmlrpc_env * const envP,
static void
validateArraySize(xmlrpc_env * const envP,
const xmlrpc_value * const arrayP,
struct arrayDecomp const arrayDecomp) {
struct arrayDecomp const *_arrayDecomp) {

struct arrayDecomp const arrayDecomp = *_arrayDecomp;
unsigned int size;

size = xmlrpc_array_size(envP, arrayP);
Expand All @@ -284,10 +286,12 @@ validateArraySize(xmlrpc_env * const envP,
static void
parsearray(xmlrpc_env * const envP,
const xmlrpc_value * const arrayP,
struct arrayDecomp const arrayDecomp,
struct arrayDecomp const *_arrayDecomp,
bool const oldstyleMemMgmt) {

validateArraySize(envP, arrayP, arrayDecomp);
struct arrayDecomp const arrayDecomp = *_arrayDecomp;

validateArraySize(envP, arrayP, &arrayDecomp);

if (!envP->fault_occurred) {
unsigned int doneCnt;
Expand Down Expand Up @@ -324,9 +328,10 @@ parsearray(xmlrpc_env * const envP,
static void
parsestruct(xmlrpc_env * const envP,
xmlrpc_value * const structP,
struct structDecomp const structDecomp,
struct structDecomp const *_structDecomp,
bool const oldstyleMemMgmt) {

struct structDecomp const structDecomp = *_structDecomp;
unsigned int doneCount;

doneCount = 0; /* No members done yet */
Expand Down Expand Up @@ -569,7 +574,7 @@ decomposeValueWithTree(xmlrpc_env * const envP,
"%s, but the '(...)' specifier requires type ARRAY",
xmlrpc_type_name(xmlrpc_value_type(valueP)));
else
parsearray(envP, valueP, decompRootP->store.Tarray,
parsearray(envP, valueP, &decompRootP->store.Tarray,
oldstyleMemMgmt);
break;

Expand All @@ -580,7 +585,7 @@ decomposeValueWithTree(xmlrpc_env * const envP,
"%s, but the '{...}' specifier requires type STRUCT",
xmlrpc_type_name(xmlrpc_value_type(valueP)));
else
parsestruct(envP, valueP, decompRootP->store.Tstruct,
parsestruct(envP, valueP, &decompRootP->store.Tstruct,
oldstyleMemMgmt);
break;

Expand Down
2 changes: 2 additions & 0 deletions libs/xmlrpc-c/src/xmlrpc_server_abyss.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,11 @@ sendResponse(xmlrpc_env * const envP,

ResponseStatus(abyssSessionP, 200);

#if 0 /* Uncomment once http_cookie is not NULL again */
if (http_cookie)
/* There's an auth cookie, so pass it back in the response. */
addAuthCookie(envP, abyssSessionP, http_cookie);
#endif

if ((size_t)(uint32_t)len != len)
xmlrpc_faultf(envP, "XML-RPC method generated a response too "
Expand Down
11 changes: 7 additions & 4 deletions libs/xmlrpc-c/src/xmlrpc_server_cgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ xmlrpc_server_cgi_process_call(xmlrpc_registry * const registryP) {
size_t input_size, output_size;
int code;
char *message;
char *err = NULL;

/* Error-handling preconditions. */
xmlrpc_env_init(&env);
Expand All @@ -209,13 +210,13 @@ xmlrpc_server_cgi_process_call(xmlrpc_registry * const registryP) {
}
if (!type || !xmlrpc_strneq(type, "text/xml", strlen("text/xml"))) {
char *template = "Expected content type: \"text/xml\", received: \"%s\"";
size_t err_len = strlen(template) + strlen(type) + 1;
char *err = malloc(err_len);
size_t err_len = strlen(template) + (type ? strlen(type) : 0) + 1;

(void)snprintf(err, err_len, template, type);
err = malloc(err_len);

(void)snprintf(err, err_len, template, (type ? type : ""));
code = 400; message = "Bad Request";
XMLRPC_FAIL(&env, XMLRPC_INTERNAL_ERROR, err);
free(err);
}
if (!length_str) {
code = 411; message = "Length Required";
Expand Down Expand Up @@ -254,6 +255,8 @@ xmlrpc_server_cgi_process_call(xmlrpc_registry * const registryP) {
send_xml(output_data, output_size);

cleanup:
if (err)
free(err);
if (input)
xmlrpc_mem_block_free(input);
if (output)
Expand Down