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

Bug fixes #75

Closed
14 changes: 10 additions & 4 deletions backends/guest/common/verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ static int get_current_esl_data(const uint8_t *esl_file, uint8_t **current_esl_d
size_t buffer_size = 0;
uint8_t *buffer = NULL;

if (is_file((char *)esl_file) != SUCCESS)
if (is_file((char *)esl_file) != SUCCESS) {
prlog(PR_ERR, "ERROR: %s is not a valid file\n", (char *)esl_file);
return INVALID_FILE;
}

buffer = (uint8_t *)get_data_from_file((char *)esl_file, SIZE_MAX, &buffer_size);
if (buffer != NULL) {
Expand All @@ -112,7 +114,7 @@ static int get_current_esl_data(const uint8_t *esl_file, uint8_t **current_esl_d
}
}
} else
return INVALID_FILE;
prlog(PR_WARNING, "WARNING: %s file does not have data\n", (char *)esl_file);
Comment on lines -112 to +117
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we not returning an error code here? It seems like this can only be reached if we fail to allocate memory for the file, or fail to read from the file (is_file checks that it exists and can be opened, which does return an error code). In both cases, this should be signaled to the calling function that something went wrong.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional note: it appears get_auth_data() does return INVALID_FILE in its similar error else case, around ~L147

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged, we should return INVALID_FILE in this case as it will avoid unnecessary operations at a later stage.


*current_esl_data = buffer;
*current_esl_data_size = buffer_size;
Expand All @@ -130,8 +132,10 @@ static int get_auth_data(const char *auth_file, uint8_t **auth_data, size_t *aut
size_t buffer_size = 0;
uint8_t *buffer = NULL;

if (is_file((char *)auth_file) != SUCCESS)
if (is_file((char *)auth_file) != SUCCESS) {
prlog(PR_ERR, "ERROR: %s is not a valid file\n", (char *)auth_file);
return INVALID_FILE;
}

buffer = (uint8_t *)get_data_from_file((char *)auth_file, SIZE_MAX, &buffer_size);
if (buffer != NULL) {
Expand All @@ -140,8 +144,10 @@ static int get_auth_data(const char *auth_file, uint8_t **auth_data, size_t *aut
free(buffer);
return rc;
}
} else
} else {
prlog(PR_WARNING, "WARNING: %s file does not have data\n", (char *)auth_file);
return INVALID_FILE;
}

*append_update = extract_append_header(buffer, buffer_size);
*auth_data = buffer;
Expand Down
Loading