Skip to content

Sbat code generation improves - #793

Merged
vathpela merged 18 commits into
rhboot:mainfrom
freddy77:sbat_gen
Sep 23, 2026
Merged

vathpela merged 18 commits into
rhboot:mainfrom
freddy77:sbat_gen

Conversation

@freddy77

Copy link
Copy Markdown
Contributor

This PR contains improves to the code to generate SBAT files from SbatLevel_Variable.txt.
Mostly are style changes, some others more strict checks in order to avoid some possible errors.
Specific commits contain more explanation.

  • Make some functions static
  • Constify some variables
  • Fix readfile error check
  • Factor out and reuse function to clear revocation list
  • Use tabs for indentation
  • Use bool for epochfound
  • Use unsigned for date field
  • Reduce indentation
  • Check file read error
  • Restrict some variable scope
  • Make errors more verbose
  • Add more explicit check on revocation list format
  • Make sure revocation string is always terminated
  • Handle not newline terminated last line correctly
  • Better checks for revocation lines
  • Minor output format style changes
  • Don't ignore first program argument
  • Declare parameters for writefile function

@freddy77

Copy link
Copy Markdown
Contributor Author

How to add some reviewers?

@freddy77

Copy link
Copy Markdown
Contributor Author

ping

Not used outside of the program.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
They should not be changed.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
The function was always returning true (!= 0), make it returns 0
on success like writefile function.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
…tion list

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
The rest of the file use tabs.
Just style change.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
More readable.
Just style change.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
The number can't be negative, this allows sscanf to be more strict
about it.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Use continue to reduce function indentation.
Just style change.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Although unlikely fgets can return NULL with file read errors.
Detect them.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Just style change.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Give some indication of the failures.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
The epoch line should be the first revocation list.
There should be no 2 epoch revocations.
Other revocations should be after the epoch.
These should be detected probably by compiling the resulting
code but better to be explicit.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
In case the revocation string is the epoch revocation the
string was not terminated.
Currently the string is not used but better to be safer.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
…ctly

The code was potentially stripping last not-newline character from
last line.
Although most editors finish text files with a new line this is not
always true and could lead to security issues (think about a
"component,12" revocation parsed as a "component,1" revocation).
Normalize the string line stripping only the newline terminator.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Make sure they are in the format XXXX,nn where X are not commas or
spaces and n are just digits.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Add an "autogenerated" comment.
Separate default GEN_SBAT_VAR_DEFS_H_ definition with an extra
empty line.
No functional changes.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
If you had more than 1 argument the first was ignored treating
as no arguments were given.
Instead ignore remaining argument.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
No parameters declaration is more K&R or C++ style.
Some recent compilers complain about it.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
@codecov

codecov Bot commented Sep 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.82%. Comparing base (96afee7) to head (199cd6f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #793   +/-   ##
=======================================
  Coverage   58.82%   58.82%           
=======================================
  Files          24       24           
  Lines        4223     4223           
  Branches      654      654           
=======================================
  Hits         2484     2484           
  Misses       1468     1468           
  Partials      271      271           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vathpela
vathpela merged commit e5d68a9 into rhboot:main Sep 23, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants