Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15-SP4
pacemaker.34782
bsc#1206761-0001-High-tools-Fix-a-segfault-in-e...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File bsc#1206761-0001-High-tools-Fix-a-segfault-in-error-handling-in-crm_r.patch of Package pacemaker.34782
From 074c56362fc4f73953d2fb436bd90cef7a51d229 Mon Sep 17 00:00:00 2001 From: Chris Lumens <clumens@redhat.com> Date: Mon, 18 Jul 2022 13:55:00 -0400 Subject: [PATCH] High: tools: Fix a segfault in error handling in crm_resource. First, we need to allocate the right amount of memory for printing error messages. Add space for the initial "non-option..." string and another space for the NULL terminator on a string vector. I think what happened here is that the "non-option..." string is not terminated with a newline, making it appear as if it is the same string as the first extra command line parameter string. However, it does actually take up its own slot in the string vector and so needs a slot allocated for it. So while I'm at it, add the newline back in. It appears to have been incorrectly removed when crm_resource was converted to using GError instead of CMD_ERR. Fixes T522 See: clbz#5496 --- tools/crm_resource.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) Index: pacemaker-2.0.5+20201202.ba59be712/tools/crm_resource.c =================================================================== --- pacemaker-2.0.5+20201202.ba59be712.orig/tools/crm_resource.c +++ pacemaker-2.0.5+20201202.ba59be712/tools/crm_resource.c @@ -1591,19 +1591,25 @@ main(int argc, char **argv) CRM_ASSERT(len > 0); - strv = calloc(len, sizeof(char *)); - strv[0] = strdup("non-option ARGV-elements:"); + /* Add 1 for the strv[0] string below, and add another 1 for the NULL + * at the end of the array so g_strjoinv knows when to stop. + */ + strv = calloc(len+2, sizeof(char *)); + strv[0] = strdup("non-option ARGV-elements:\n"); for (gchar **s = options.remainder; *s; s++) { strv[i] = crm_strdup_printf("[%d of %d] %s\n", i, len, *s); i++; } + strv[i] = NULL; + msg = g_strjoinv("", strv); g_set_error(&error, PCMK__EXITC_ERROR, CRM_EX_USAGE, "%s", msg); g_free(msg); - for(i = 0; i < len; i++) { + /* Don't try to free the last element, which is just NULL. */ + for(i = 0; i < len+1; i++) { free(strv[i]); } free(strv);
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