-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
guest: clean up and unify reading the timestamp from a variable buffer #76
Milestone
Comments
erichte-ibm
pushed a commit
to erichte-ibm/secvarctl
that referenced
this issue
Nov 17, 2023
Move the existing print_timestamp function to common/util, and add a new helper to handle reading and printing a timestamp from a variable buffer. Prints the timestamp when using the read command, and when using verbose levels in the verify command. This commit is part of a larger work in progress on factoring out loading data from a variable vs a file, see more information in open-power#76. Co-developed-by: Eric Richter <[email protected]> Signed-off-by: Sudhakar Kuppusamy <[email protected]>
This was referenced Nov 17, 2023
Merged
nick-child-ibm
pushed a commit
that referenced
this issue
Dec 8, 2023
Move the existing print_timestamp function to common/util, and add a new helper to handle reading and printing a timestamp from a variable buffer. Prints the timestamp when using the read command, and when using verbose levels in the verify command. This commit is part of a larger work in progress on factoring out loading data from a variable vs a file, see more information in #76. Co-developed-by: Eric Richter <[email protected]> Signed-off-by: Sudhakar Kuppusamy <[email protected]>
Resolved in #77 |
nick-child-ibm
pushed a commit
that referenced
this issue
Feb 6, 2024
Move the existing print_timestamp function to common/util, and add a new helper to handle reading and printing a timestamp from a variable buffer. Prints the timestamp when using the read command, and when using verbose levels in the verify command. This commit is part of a larger work in progress on factoring out loading data from a variable vs a file, see more information in #76. Co-developed-by: Eric Richter <[email protected]> Signed-off-by: Sudhakar Kuppusamy <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In multiple places in the code (namely
guest_svc_read.c:read_path()
), we load in data from a variable, then proceed to do some level of validation which mostly consists of checking that the buffer is an expected size before doing any parsing. As asked in PR #75 , the "expected" size of a buffer should be defined, documented, and probably abstracted out so that other places of the code can call a function to read in a particular variable and do this same validation.From my understanding, the following conditions should be checked and handled on the buffer size:
size == 0
→ error case, likely invalid file or some other I/O error. variables should not be completely empty0 < size < HEADER_LEN
→ error case, variable must contain at least the 16-byte headersize == HEADER_LEN
→ valid case, variable exists but contains no datasize > HEADER_LEN
→ valid case, data exists and can be parsedData read from a variable contains a header of 16 bytes, consisting of a 1-byte version number, then 15 bytes of timestamp, truncating the last pad so that the header remains aligned.
Cleaning this up will probably looking some like:
variable_from_path()
TIMESTAMP_LEN
andTIMESTAMP_LEN - 1
when referring to this headerThe text was updated successfully, but these errors were encountered: