Skip to content
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

Don't attempt to print an ESL from a zero-sized buffer #87

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

erichte-ibm
Copy link
Collaborator

Minor fix. In guest mode, when printing a variable that has been cleared, a scary error message is printed claiming there is no remaining space to unpack an ESL.

$ ./bin/secvarctl -m guest read -n dbx -p tmp
READING dbx :
	Timestamp: 2023-04-07 09:18:56 UTC
Not enough space left for an ESL when unpacking buffer: 0 bytes remain
Error reading from esl buffer: 1
RESULT: FAILURE

Since the variable has been cleared, there obviously is no data, therefore the buffer is empty, however there is still the timestamp that should be printed. Therefore, handle cases when printing an empty buffer to indicate that there is no data to print:

$ ./bin/secvarctl -m guest read -n dbx -p tmp
make: Nothing to be done for 'all'.
READING dbx :
	Timestamp: 2023-04-07 09:18:56 UTC
(empty)
RESULT: SUCCESS

I'm open to changing or omitting the (empty) string, figured it was better to be explicit about the lack of data.

Currently, print_esl_buffer() passes along the input buffer and size to
next_esl_from_buffer(), which will immediately error since a buffer size
of zero obviously cannot contain an ESL.

This can sometimes happen when printing a variable that contains a
timestamp but no data -- the most obvious example being a variable that
was cleared.

Therefore, a message should be printed to indicate there is no data,
rather than an error message that should be reserved for when the data
is actually malformed.

Signed-off-by: Eric Richter <erichte@linux.ibm.com>
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.

None yet

1 participant