Skip to content

Commit

Permalink
guest/read: don't attempt to print an ESL from a zero-sized buffer
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
erichte-ibm committed Jul 23, 2024
1 parent 73d91fa commit 9dc1ba7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions backends/guest/common/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ int print_esl_buffer(const uint8_t *buffer, size_t buffer_size, const char *var_
} curr_esl;
curr_esl.raw = NULL;

// Do not bother reading from zero-size buffers
if (buffer_size == 0) {
printf("(empty)\n");
return SUCCESS;
}

rc = next_esl_from_buffer(buffer, buffer_size, &curr_esl.raw, &esl_data_size);
if (rc) {
prlog(PR_ERR, "Error reading from esl buffer: %d\n", rc);
Expand Down

0 comments on commit 9dc1ba7

Please sign in to comment.