-
Notifications
You must be signed in to change notification settings - Fork 422
Removing warnings from libencrypt and libdecrypt #2629
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
Conversation
@tangxifan some QoR tests are failing in CI which are not related to the changes in this PR. |
@behzadmehmood-rs Thanks. The CI failures are expected then. Good job. |
@Tulong4Dev Please help on reviewing this PR. |
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.
did a quick screening and suggested to make some minor fix.
meanwhile, i'm afraid there could be some memory leakage which i suggest to use valgrind to detect and verify it, if possible.
libs/libdecrypt/src/decryption.cpp
Outdated
* | ||
* @param input The base64-encoded input string. | ||
* @return The decoded output string. | ||
* @param encoded he base64-encoded input string. |
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.
"he" -> "the"
libs/libpugiutil/src/pugixml_loc.cpp
Outdated
std::ptrdiff_t offset = 0; | ||
char buffer[1024]; | ||
std::size_t size; | ||
//std::ptrdiff_t offset = 0; |
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.
remove the commented unused variables.
libs/libencrypt/src/encryption.cpp
Outdated
unsigned char iv[EVP_MAX_IV_LENGTH]; | ||
if (RAND_bytes(iv, sizeof(iv)) != 1) { | ||
std::cerr << "Error generating IV." << std::endl; | ||
return -1; |
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.
should return a Boolean here.
libs/libencrypt/src/encryption.cpp
Outdated
RSA* publicKey = loadPublicKey(publicKeyFile); | ||
OpenSSL_add_all_algorithms(); | ||
ERR_load_crypto_strings(); | ||
unsigned char sessionKey[16]; |
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.
can we avoid using constant number here ("16") directly? we can use a meaningful constant variable to represent it.
I have made the changes, now I will run it with valgrind. |
@Tulong4Dev , I have also updated the code to avoid memory leaks. |
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.
LGTM. In addition, I'd suggest to add a test with encrypt/decrypt so VTR's Valgrind test flow could help to detect potential memory leak.
Is it okay to put the test data and code in |
@Tulong4Dev I have added a test but I could not update workflow file properly. Can you please suggest how should I run the test? |
@tangxifan , @Tulong4Dev please review again. Code is updated and test has been added. |
#endif | ||
|
||
// Function to create a sample XML file for testing | ||
void createTestXMLFile(const std::string& filePath) { |
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.
@Tulong4Dev Please check if the test provided is sufficient. If a local run on the unit test is o.k., I suggest to merge this PR. This PR is currently a blocking factor on another PR #2637
Description
This change simply removes warnings due to type casting.
Related Issue
Motivation and Context
It is necessary for a warning free CI.
How Has This Been Tested?
Types of changes
Checklist: