mirror of
https://github.com/opnsense/src.git
synced 2026-06-11 09:41:03 -04:00
elfctl: fix -e invalid operation error handling
Validate the operation prior to parsing the feature string, so that e.g.
-e 0x1 reports invalid operation '0' rather than invalid feature 'x11'.
Also make it an error rather than a warning, so that it is not repeated
if multiple files are specified.
(Previously an invalid operation resulted in a segfault.)
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
(cherry picked from commit b8185579f4)
This commit is contained in:
parent
e1465e2e1e
commit
f6c74bacf5
1 changed files with 4 additions and 4 deletions
|
|
@ -230,6 +230,10 @@ convert_to_feature_val(char *feature_str, uint32_t *feature_val)
|
|||
input = 0;
|
||||
operation = *feature_str;
|
||||
feature_str++;
|
||||
|
||||
if (operation != '+' && operation != '-' && operation != '=')
|
||||
errx(1, "'%c' not an operator - use '+', '-', '='", operation);
|
||||
|
||||
len = nitems(featurelist);
|
||||
while ((feature = strsep(&feature_str, ",")) != NULL) {
|
||||
for (i = 0; i < len; ++i) {
|
||||
|
|
@ -278,10 +282,6 @@ convert_to_feature_val(char *feature_str, uint32_t *feature_val)
|
|||
*feature_val = input;
|
||||
} else if (operation == '-') {
|
||||
*feature_val &= ~input;
|
||||
} else {
|
||||
warnx("'%c' not an operator - use '+', '-', '='",
|
||||
feature_str[0]);
|
||||
return (false);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue