Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP4:GA
pacemaker.13547
pacemaker-snprintf-use-sizeof.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File pacemaker-snprintf-use-sizeof.patch of Package pacemaker.13547
commit 1bf85a3b9a2801216af279e0c2ad555a25e34733 Author: Jan Pokorný <jpokorny@redhat.com> Date: Wed Feb 15 13:06:50 2017 +0100 Fix: snprintf: use sizeof(X) as size + prevent off-by-ones Being unnecessarily pesimistic snprintf target sizing may lead to unwarranted memory consumption. At that opportunity, also remove superfluous initial string initialization/termination in two affected instances. Index: pacemaker-1.1.16+20170320.77ea74d/fencing/commands.c =================================================================== --- pacemaker-1.1.16+20170320.77ea74d.orig/fencing/commands.c +++ pacemaker-1.1.16+20170320.77ea74d/fencing/commands.c @@ -185,7 +185,7 @@ get_action_timeout(stonith_device_t * de } /* If the device config specified an action-specific timeout, use it */ - snprintf(buffer, sizeof(buffer) - 1, "pcmk_%s_timeout", action); + snprintf(buffer, sizeof(buffer), "pcmk_%s_timeout", action); value = g_hash_table_lookup(device->params, buffer); if (value) { return atoi(value); Index: pacemaker-1.1.16+20170320.77ea74d/lib/common/logging.c =================================================================== --- pacemaker-1.1.16+20170320.77ea74d.orig/lib/common/logging.c +++ pacemaker-1.1.16+20170320.77ea74d/lib/common/logging.c @@ -565,7 +565,7 @@ crm_log_filter(struct qb_log_callsite *c do { offset = next; next = strchrnul(offset, ','); - snprintf(token, 499, "%.*s", (int)(next - offset), offset); + snprintf(token, sizeof(token), "%.*s", (int)(next - offset), offset); tag = g_quark_from_string(token); crm_info("Created GQuark %u from token '%s' in '%s'", tag, token, trace_tags); Index: pacemaker-1.1.16+20170320.77ea74d/lib/fencing/st_client.c =================================================================== --- pacemaker-1.1.16+20170320.77ea74d.orig/lib/fencing/st_client.c +++ pacemaker-1.1.16+20170320.77ea74d/lib/fencing/st_client.c @@ -517,15 +517,14 @@ make_args(const char *agent, const char CRM_CHECK(action != NULL, return NULL); - buffer[511] = 0; - snprintf(buffer, 511, "pcmk_%s_action", action); + snprintf(buffer, sizeof(buffer), "pcmk_%s_action", action); if (device_args) { value = g_hash_table_lookup(device_args, buffer); } if (value == NULL && device_args) { /* Legacy support for early 1.1 releases - Remove for 1.4 */ - snprintf(buffer, 511, "pcmk_%s_cmd", action); + snprintf(buffer, sizeof(buffer), "pcmk_%s_cmd", action); value = g_hash_table_lookup(device_args, buffer); } @@ -699,7 +698,7 @@ stonith_action_create(const char *agent, const char *st_dev_id_key = CRM_META "_" F_STONITH_DEVICE; const char *st_dev_id_value = NULL; - snprintf(buffer, 511, "pcmk_%s_retries", _action); + snprintf(buffer, sizeof(buffer), "pcmk_%s_retries", _action); value = g_hash_table_lookup(device_args, buffer); if (value) { Index: pacemaker-1.1.16+20170320.77ea74d/mcp/pacemaker.c =================================================================== --- pacemaker-1.1.16+20170320.77ea74d.orig/mcp/pacemaker.c +++ pacemaker-1.1.16+20170320.77ea74d/mcp/pacemaker.c @@ -606,13 +606,11 @@ update_process_peers(void) struct iovec *iov; int rc = 0; - memset(buffer, 0, SIZEOF(buffer)); - if (local_name) { - rc = snprintf(buffer, SIZEOF(buffer) - 1, "<node uname=\"%s\" proclist=\"%u\"/>", + rc = snprintf(buffer, SIZEOF(buffer), "<node uname=\"%s\" proclist=\"%u\"/>", local_name, get_process_list()); } else { - rc = snprintf(buffer, SIZEOF(buffer) - 1, "<node proclist=\"%u\"/>", get_process_list()); + rc = snprintf(buffer, SIZEOF(buffer), "<node proclist=\"%u\"/>", get_process_list()); } crm_trace("Sending %s", buffer); Index: pacemaker-1.1.16+20170320.77ea74d/tools/crm_simulate.c =================================================================== --- pacemaker-1.1.16+20170320.77ea74d.orig/tools/crm_simulate.c +++ pacemaker-1.1.16+20170320.77ea74d/tools/crm_simulate.c @@ -558,7 +558,7 @@ profile_all(const char *dir) if (file_num > 0) { struct stat prop; - char buffer[FILENAME_MAX + 1]; + char buffer[FILENAME_MAX]; while (file_num--) { if ('.' == namelist[file_num]->d_name[0]) { @@ -571,7 +571,7 @@ profile_all(const char *dir) } lpc++; - snprintf(buffer, FILENAME_MAX, "%s/%s", dir, namelist[file_num]->d_name); + snprintf(buffer, sizeof(buffer), "%s/%s", dir, namelist[file_num]->d_name); if (stat(buffer, &prop) == 0 && S_ISREG(prop.st_mode)) { profile_one(buffer); }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor