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
qualifying data as hex string or binary file and manpage fix #1822
qualifying data as hex string or binary file and manpage fix #1822
Conversation
} | ||
} | ||
|
||
TPM2B_NONCE policy_qualifier = { .size = (uint16_t) file_size }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@idesai this code is wrong, and broken. file_size is a long, which can hold a value larger than 16 bits. You could be reading only partial files as you cast it done without checking that it is not larger than UINT16_MAX.
Additionally, this code was over complicated... all you need to do is:
- set a size to the max size of the buffer
- call files_load_bytes_from_path(), which will read up to max bytes and error out if the file hasn't been fully consumed as well as update the size parameter to the actual size in bytes read.
- go on your way using the contents, validate size if your expecting something certain.
return tool_rc_general_error; | ||
} | ||
|
||
*policy_qualifier = malloc(file_size + sizeof(uint16_t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@idesai this code is wild.
- if you need to malloc a TPM2B_* data type, just malloc based on the sizeof of the type. We're not counting the few bytes it wastes.
- Why did you even malloc it? There was no point in complicating the flow with needing to free and dealing with oom. Just stack allocate and pass a pointer, which is funny, as a lot of the other parameter structures worked like that.
This comment has been minimized.
This comment has been minimized.
Codecov Report
@@ Coverage Diff @@
## master #1822 +/- ##
==========================================
+ Coverage 74.39% 74.53% +0.13%
==========================================
Files 115 115
Lines 11553 11501 -52
==========================================
- Hits 8595 8572 -23
+ Misses 2958 2929 -29
Continue to review full report at Codecov.
|
5f5f013
to
1f49ace
Compare
Unify the -q option by allowing them to be a file or hex array for inputs. Fixes: tpm2-software#1631 Signed-off-by: William Roberts <william.c.roberts@intel.com>
tpm2_nvextend was identical to tpm2_nvsetbits due to a copy + paste error. Correct the manpage by making it reflect the tpm2_nvextend tool. Fixes: tpm2-software#1820 Signed-off-by: William Roberts <william.c.roberts@intel.com>
Fixes: #1631
Fixes: #1820