Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP2:Update
grub2.24426
0027-kern-parser-Introduce-terminate_arg-helper...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0027-kern-parser-Introduce-terminate_arg-helper.patch of Package grub2.24426
From bfa16748438f2ad8b6cb3a23cdeb9eddd04cc4d5 Mon Sep 17 00:00:00 2001 From: Chris Coulson <chris.coulson@canonical.com> Date: Thu, 7 Jan 2021 19:53:55 +0000 Subject: [PATCH 27/45] kern/parser: Introduce terminate_arg() helper process_char() and grub_parser_split_cmdline() use similar code for terminating the most recent argument. Add a helper function for this. Signed-off-by: Chris Coulson <chris.coulson@canonical.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> --- grub-core/kern/parser.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/grub-core/kern/parser.c b/grub-core/kern/parser.c index 0d3582bd8..572c67089 100644 --- a/grub-core/kern/parser.c +++ b/grub-core/kern/parser.c @@ -129,6 +129,16 @@ add_var (char *varname, char **bp, char **vp, *((*bp)++) = *val; } +static void +terminate_arg (char *buffer, char **bp, int *argc) +{ + if (*bp != buffer && *((*bp) - 1) != '\0') + { + *((*bp)++) = '\0'; + (*argc)++; + } +} + static grub_err_t process_char (char c, char *buffer, char **bp, char *varname, char **vp, grub_parser_state_t state, int *argc, @@ -157,11 +167,7 @@ process_char (char c, char *buffer, char **bp, char *varname, char **vp, * Don't add more than one argument if multiple * spaces are used. */ - if (*bp != buffer && *((*bp) - 1) != '\0') - { - *((*bp)++) = '\0'; - (*argc)++; - } + terminate_arg (buffer, bp, argc); } else if (use) *((*bp)++) = use; @@ -232,11 +238,8 @@ grub_parser_split_cmdline (const char *cmdline, variable. */ add_var (varname, &bp, &vp, state, GRUB_PARSER_STATE_TEXT); - if (bp != buffer && *(bp - 1)) - { - *(bp++) = '\0'; - (*argc)++; - } + /* Ensure that the last argument is terminated. */ + terminate_arg (buffer, &bp, argc); /* If there are no args, then we're done. */ if (!*argc) -- 2.26.2
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