Skip to content

Commit

Permalink
Merge pull request #2075 from wenningerk/2.0-prepare-2.0.4
Browse files Browse the repository at this point in the history
2.0 prepare 2.0.4
  • Loading branch information
wenningerk authored May 15, 2020
2 parents ea0c643 + fe60124 commit 5319fe7
Show file tree
Hide file tree
Showing 21 changed files with 90 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ publican.cfg
/doc/sphinx/*/_build
/doc/sphinx/*/conf.py
/lib/common/md5.c
/maint/testcc
/maint/testcc_*_h
/maint/mocked/based
scratch
/tools/attrd_updater
Expand Down
4 changes: 3 additions & 1 deletion daemons/execd/execd_alerts.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ process_lrmd_alert_exec(pcmk__client_t *client, uint32_t id, xmlNode *request)
GHashTable *params = NULL;
struct alert_cb_s *cb_data = NULL;

if ((alert_id == NULL) || (alert_path == NULL)) {
if ((alert_id == NULL) || (alert_path == NULL) ||
(client == NULL) || (client->id == NULL)) { /* hint static analyzer */
return -EINVAL;
}
if (draining_alerts) {
Expand All @@ -112,6 +113,7 @@ process_lrmd_alert_exec(pcmk__client_t *client, uint32_t id, xmlNode *request)
CRM_CHECK(cb_data != NULL,
rc = -ENOMEM; goto err);

/* coverity[deref_ptr] False Positive */
cb_data->client_id = strdup(client->id);
CRM_CHECK(cb_data->client_id != NULL,
rc = -ENOMEM; goto err);
Expand Down
2 changes: 2 additions & 0 deletions daemons/fenced/fenced_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,8 @@ add_result(remote_fencing_op_t *op, const char *host, int ndevices, xmlNode *xml
st_query_result_t *result = calloc(1, sizeof(st_query_result_t));
xmlNode *child;

// cppcheck seems not to understand the abort logic in CRM_CHECK
// cppcheck-suppress memleak
CRM_CHECK(result != NULL, return NULL);
result->host = strdup(host);
result->devices = crm_str_table_new();
Expand Down
2 changes: 2 additions & 0 deletions lib/cluster/cpg.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,8 @@ send_cluster_text(enum crm_ais_msg_class msg_class, const char *data,
msg->compressed_size = new_size;

} else {
// cppcheck seems not to understand the abort logic in realloc_safe
// cppcheck-suppress memleak
msg = realloc_safe(msg, msg->header.size);
memcpy(msg->data, data, msg->size);
}
Expand Down
5 changes: 4 additions & 1 deletion lib/common/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ pcmk__cmdline_preproc(char **argv, const char *special) {
}

if (g_get_prgname() == NULL && argv && *argv) {
g_set_prgname(g_path_get_basename(*argv));
gchar *basename = g_path_get_basename(*argv);

g_set_prgname(basename);
g_free(basename);
}

arr = g_ptr_array_new();
Expand Down
2 changes: 2 additions & 0 deletions lib/common/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ pcmk__build_path(const char *path_c, mode_t mode)
int rc = pcmk_rc_ok;
char *path = strdup(path_c);

// cppcheck seems not to understand the abort logic in CRM_CHECK
// cppcheck-suppress memleak
CRM_CHECK(path != NULL, return -ENOMEM);
for (len = strlen(path); offset < len; offset++) {
if (path[offset] == '/') {
Expand Down
2 changes: 1 addition & 1 deletion lib/common/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ pcmk__ipc_prepare_iov(uint32_t request, xmlNode *message,

header = calloc(1, sizeof(struct crm_ipc_response_header));
if (header == NULL) {
return errno;
return ENOMEM; /* errno mightn't be set by allocator */
}

buffer = dump_xml_unformatted(message);
Expand Down
2 changes: 2 additions & 0 deletions lib/common/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,8 @@ crm_log_args(int argc, char **argv)

logged = 1;

// cppcheck seems not to understand the abort logic in realloc_safe
// cppcheck-suppress memleak
for (; lpc < argc; lpc++) {
if (argv[lpc] == NULL) {
break;
Expand Down
2 changes: 2 additions & 0 deletions lib/common/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ create_long_opts(pcmk__cli_option_t *long_options)
long_opts[index].val = '_';
index++;

// cppcheck seems not to understand the abort-logic in realloc_safe
// cppcheck-suppress memleak
for (lpc = 0; long_options[lpc].name != NULL; lpc++) {
if (long_options[lpc].name[0] == '-') {
continue;
Expand Down
2 changes: 2 additions & 0 deletions lib/common/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,8 @@ connect_socket_retry(int sock, const struct sockaddr *addr, socklen_t addrlen,
*timer_id = timer;
}

// timer callback should be taking care of cb_data
// cppcheck-suppress memleak
return pcmk_rc_ok;
}

Expand Down
8 changes: 6 additions & 2 deletions lib/common/xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -2292,6 +2292,8 @@ decompress_file(const char *filename)
}

rc = BZ_OK;
// cppcheck seems not to understand the abort-logic in realloc_safe
// cppcheck-suppress memleak
while (rc == BZ_OK) {
buffer = realloc_safe(buffer, XML_BUFFER_SIZE + length + 1);
read_len = BZ2_bzRead(&rc, bz_file, buffer + length, XML_BUFFER_SIZE);
Expand Down Expand Up @@ -3223,7 +3225,8 @@ crm_xml_dump(xmlNode * data, int options, char **buffer, int *offset, int *max,

xmlNodeDumpOutput(xml_buffer, doc, data, 0,
(options & xml_log_option_formatted), NULL);
xmlOutputBufferWrite(xml_buffer, sizeof("\n") - 1, "\n"); /* final NL */
/* attempt adding final NL - failing shouldn't be fatal here */
(void) xmlOutputBufferWrite(xml_buffer, sizeof("\n") - 1, "\n");
if (xml_buffer->buffer != NULL) {
buffer_print(*buffer, *max, *offset, "%s",
(char *) xmlBufContent(xml_buffer->buffer));
Expand All @@ -3237,7 +3240,8 @@ crm_xml_dump(xmlNode * data, int options, char **buffer, int *offset, int *max,
}
#endif

xmlOutputBufferClose(xml_buffer);
/* asserted allocation before so there should be something to remove */
(void) xmlOutputBufferClose(xml_buffer);
return;
}

Expand Down
2 changes: 2 additions & 0 deletions lib/fencing/st_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ create_level_registration_xml(const char *node, const char *pattern,
crm_xml_add(data, XML_ATTR_STONITH_TARGET_VALUE, value);
}

// cppcheck seems not to understand the abort logic behind realloc_safe
// cppcheck-suppress memleak
for (; device_list; device_list = device_list->next) {

int adding = strlen(device_list->value);
Expand Down
7 changes: 5 additions & 2 deletions lib/gnu/md5.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,13 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
if (left_over >= 64)
{
md5_process_block (ctx->buffer, 64, ctx);
left_over -= 64;
left_over &= 63; /* same as -= 64 but easier to understand
for static analysis
*/
/* The regions in the following copy operation cannot overlap,
because left_over ≤ 64. */
memcpy (ctx->buffer, &ctx->buffer[16], left_over);
memcpy (ctx->buffer, &(((char *) ctx->buffer)[64]), left_over);
/* cast to char * as hint for static analysis */
}
ctx->buflen = left_over;
}
Expand Down
15 changes: 11 additions & 4 deletions lib/pacemaker/pcmk_sched_clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,11 @@ can_run_instance(pe_resource_t * rsc, pe_node_t * node, int limit)
return NULL;
}

if (can_run_resources(node) == FALSE) {
if (!node) {
/* make clang analyzer happy */
goto bail;

} else if (can_run_resources(node) == FALSE) {
goto bail;

} else if (is_set(rsc->flags, pe_rsc_orphan)) {
Expand Down Expand Up @@ -1402,9 +1406,11 @@ probe_anonymous_clone(pe_resource_t *rsc, pe_node_t *node,
pe_node_t *local_node = NULL;
pe_resource_t *child_rsc = (pe_resource_t *) child_iter->data;

local_node = child_rsc->fns->location(child_rsc, NULL, FALSE);
if (local_node && (local_node->details == node->details)) {
child = child_rsc;
if (child_rsc) { /* make clang analyzer happy */
local_node = child_rsc->fns->location(child_rsc, NULL, FALSE);
if (local_node && (local_node->details == node->details)) {
child = child_rsc;
}
}
}
}
Expand All @@ -1413,6 +1419,7 @@ probe_anonymous_clone(pe_resource_t *rsc, pe_node_t *node,
if (child == NULL) {
child = rsc->children->data;
}
CRM_ASSERT(child);
return child->cmds->create_probe(child, node, complete, force, data_set);
}

Expand Down
3 changes: 2 additions & 1 deletion lib/pacemaker/pcmk_sched_graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,8 @@ action2xml(pe_action_t * action, gboolean as_input, pe_working_set_t *data_set)
hash2smartfield((gpointer)"pcmk_external_ip", (gpointer)value, (gpointer)args_xml);
}

if (pe__is_guest_node(action->node)) {
if (action->node && /* make clang analyzer happy */
pe__is_guest_node(action->node)) {
pe_node_t *host = NULL;
enum action_tasks task = text2task(action->task);

Expand Down
8 changes: 6 additions & 2 deletions replace/scandir.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,15 @@ scandir(const char *directory_name,

/* Get initial list space and open directory. */

if (directory = opendir(directory_name), directory == NULL)
if ((directory = opendir(directory_name)) == NULL) {
return -1;
}

if ((array = (struct dirent **)malloc(allocated * sizeof(struct dirent *))) == NULL)
if ((array = (struct dirent **)malloc(allocated * sizeof(struct dirent *)))
== NULL) {
closedir(directory);
return -1;
}

/* Read entries in the directory. */

Expand Down
60 changes: 29 additions & 31 deletions rpm/pacemaker.spec.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
# Define conditionals so that "rpmbuild --with <feature>" and
# "rpmbuild --without <feature>" can enable and disable specific features

## Add option to enable support for stonith/external fencing agents
%bcond_with stonithd

## Add option to create binaries suitable for use with profiling tools
%bcond_with profiling

## Add option to create binaries with coverage analysis
%bcond_with coverage

## Add option to skip generating documentation
## (the build tools aren't available everywhere)
%bcond_without doc

## Add option to prefix package version with "0."
## (so later "official" packages will be considered updates)
%bcond_with pre_release

## Add option to ship Upstart job files
%bcond_with upstart_job

## Add option to turn off hardening of libraries and daemon executables
%bcond_without hardening

## Add option to disable links for legacy daemon names
%bcond_without legacy_links

# Globals and defines to control package behavior (configure these as desired)

## User and group to use for nonprivileged services
Expand Down Expand Up @@ -177,37 +206,6 @@
}
%endif


# Define conditionals so that "rpmbuild --with <feature>" and
# "rpmbuild --without <feature>" can enable and disable specific features

## Add option to enable support for stonith/external fencing agents
%bcond_with stonithd

## Add option to create binaries suitable for use with profiling tools
%bcond_with profiling

## Add option to create binaries with coverage analysis
%bcond_with coverage

## Add option to skip generating documentation
## (the build tools aren't available everywhere)
%bcond_without doc

## Add option to prefix package version with "0."
## (so later "official" packages will be considered updates)
%bcond_with pre_release

## Add option to ship Upstart job files
%bcond_with upstart_job

## Add option to turn off hardening of libraries and daemon executables
%bcond_without hardening

## Add option to disable links for legacy daemon names
%bcond_without legacy_links


# Keep sane profiling data if requested
%if %{with profiling}

Expand Down
2 changes: 1 addition & 1 deletion tools/crm_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ main(int argc, char **argv)
if (g_strv_length(processed_args) < 2) {
char *help = g_option_context_get_help(context, TRUE, NULL);
fprintf(stderr, "%s", help);
free(help);
g_free(help);
return CRM_EX_USAGE;
}

Expand Down
3 changes: 3 additions & 0 deletions tools/crm_mon.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ as_html_cb(const gchar *option_name, const gchar *optarg, gpointer data, GError

if (args->output_dest != NULL) {
free(args->output_dest);
args->output_dest = NULL;
}

if (optarg != NULL) {
Expand Down Expand Up @@ -1465,6 +1466,7 @@ print_simple_status(pcmk__output_t *out, pe_working_set_t * data_set,
nodes_online++;
} else {
char *s = crm_strdup_printf("offline node: %s", node->details->uname);
/* coverity[leaked_storage] False positive */
offline_nodes = pcmk__add_word(offline_nodes, s);
free(s);
mon_ops |= mon_op_has_warnings;
Expand Down Expand Up @@ -1503,6 +1505,7 @@ print_simple_status(pcmk__output_t *out, pe_working_set_t * data_set,
free(nodes_standby_s);
free(nodes_maint_s);
}
/* coverity[leaked_storage] False positive */
}

/*!
Expand Down
5 changes: 2 additions & 3 deletions tools/crm_resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,9 @@ main(int argc, char **argv)
const char *operation = NULL;
const char *interval_spec = NULL;
const char *cib_file = getenv("CIB_file");
const char *xml_file = NULL;
GHashTable *override_params = NULL;

char *xml_file = NULL;
xmlNode *cib_xml_copy = NULL;
pe_resource_t *rsc = NULL;
bool recursive = FALSE;
Expand Down Expand Up @@ -844,7 +844,7 @@ main(int argc, char **argv)
pcmk__cli_help(flag, CRM_EX_OK);
break;
case 'x':
xml_file = strdup(optarg);
xml_file = optarg;
break;
case 'Q':
BE_QUIET = TRUE;
Expand Down Expand Up @@ -1111,7 +1111,6 @@ main(int argc, char **argv)
if (require_dataset) {
if (xml_file != NULL) {
cib_xml_copy = filename2xml(xml_file);

} else {
rc = cib_conn->cmds->query(cib_conn, NULL, &cib_xml_copy, cib_scope_local | cib_sync_call);
}
Expand Down
4 changes: 2 additions & 2 deletions tools/crm_ticket.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ const char *attr_value = NULL;
const char *attr_id = NULL;
const char *set_name = NULL;
const char *attr_default = NULL;
const char *xml_file = NULL;
char ticket_cmd = 'S';
char *xml_file = NULL;
int cib_options = cib_sync_call;

static pe_ticket_t *
Expand Down Expand Up @@ -812,7 +812,7 @@ main(int argc, char **argv)
do_force = TRUE;
break;
case 'x':
xml_file = strdup(optarg);
xml_file = optarg;
break;
case 'n':
set_name = optarg;
Expand Down

0 comments on commit 5319fe7

Please sign in to comment.