Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:FrontRunner
pacemaker.34782
pacemaker#3379-0001-Low-tools-Fix-argument-vali...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File pacemaker#3379-0001-Low-tools-Fix-argument-validation-for-crm_attribute-.patch of Package pacemaker.34782
From 88d94635bc1d1387863d7454ec99c6de70abf439 Mon Sep 17 00:00:00 2001 From: Chris Lumens <clumens@redhat.com> Date: Thu, 29 Feb 2024 15:50:04 -0500 Subject: [PATCH] Low: tools: Fix argument validation for crm_attribute update. Previously (perhaps as far back as when crm_attribute was introduced) we haven't done any validation on whether an attribute name was given along with the -v option specifying the new attribute value. Instead we just asserted. Instead, check that a name or pattern was given and if not, display an error message. The other two asserts can go, as well. options.type will always be set by the call to set_type(), and options.attr_value will be set if -v was given on the command line. Fixes T765 --- tools/crm_attribute.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) Index: pacemaker-2.0.5+20201202.ba59be712/tools/crm_attribute.c =================================================================== --- pacemaker-2.0.5+20201202.ba59be712.orig/tools/crm_attribute.c +++ pacemaker-2.0.5+20201202.ba59be712/tools/crm_attribute.c @@ -85,11 +85,11 @@ static pcmk__cli_option_t long_options[] }, { "update", required_argument, NULL, 'v', - "Update the value of the attribute/option", pcmk__option_default + "Update the value of the attribute/option (with -n or -P)", pcmk__option_default }, { "delete", no_argument, NULL, 'D', - "\tDelete the attribute/option", pcmk__option_default + "\tDelete the attribute/option (with -n or -P)", pcmk__option_default }, { "-spacer-", no_argument, NULL, '-', @@ -242,6 +242,14 @@ static pcmk__cli_option_t long_options[] { 0, 0, 0, 0 } }; +static bool +update_used_correctly(void) +{ + return (command != 'v') + || (attr_name != NULL) + || (attr_pattern != NULL); +} + int main(int argc, char **argv) { @@ -401,6 +409,12 @@ main(int argc, char **argv) crm_exit(CRM_EX_USAGE); } + if (!update_used_correctly()) { + fprintf(stderr, + "Error: must specify attribute name or pattern to update\n"); + crm_exit(CRM_EX_USAGE); + } + if (attr_pattern) { if (((command != 'v') && (command != 'D')) || !pcmk__str_eq(type, XML_CIB_TAG_STATUS, pcmk__str_casei)) {
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