mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2024-11-20 03:39:17 +01:00
Merge branch 'fix_rhash_memory_corruption' of https://github.com/nathanel23/lgogdownloader
This commit is contained in:
commit
178ca66997
2
main.cpp
2
main.cpp
@ -26,6 +26,8 @@ template<typename T> void set_vm_value(std::map<std::string, bpo::variable_value
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
rhash_library_init();
|
||||
|
||||
// Constants for option selection with include/exclude
|
||||
/* TODO: Add options to give better control for user
|
||||
For example: option to select base game and DLC installers separately,
|
||||
|
@ -59,9 +59,8 @@ std::string Util::makeRelativeFilepath(const std::string& path, const std::strin
|
||||
std::string Util::getFileHash(const std::string& filename, unsigned hash_id)
|
||||
{
|
||||
unsigned char digest[rhash_get_digest_size(hash_id)];
|
||||
char result[rhash_get_hash_length(hash_id)];
|
||||
char result[rhash_get_hash_length(hash_id) + 1];
|
||||
|
||||
rhash_library_init();
|
||||
int i = rhash_file(hash_id, filename.c_str(), digest);
|
||||
if (i < 0)
|
||||
std::cerr << "LibRHash error: " << strerror(errno) << std::endl;
|
||||
@ -74,9 +73,8 @@ std::string Util::getFileHash(const std::string& filename, unsigned hash_id)
|
||||
std::string Util::getChunkHash(unsigned char *chunk, uintmax_t chunk_size, unsigned hash_id)
|
||||
{
|
||||
unsigned char digest[rhash_get_digest_size(hash_id)];
|
||||
char result[rhash_get_hash_length(hash_id)];
|
||||
char result[rhash_get_hash_length(hash_id) + 1];
|
||||
|
||||
rhash_library_init();
|
||||
int i = rhash_msg(hash_id, chunk, chunk_size, digest);
|
||||
if (i < 0)
|
||||
std::cerr << "LibRHash error: " << strerror(errno) << std::endl;
|
||||
@ -141,7 +139,6 @@ int Util::createXML(std::string filepath, uintmax_t chunk_size, std::string xml_
|
||||
std::cout << "Getting MD5 for chunks" << std::endl;
|
||||
|
||||
rhash rhash_context;
|
||||
rhash_library_init();
|
||||
rhash_context = rhash_init(RHASH_MD5);
|
||||
if(!rhash_context)
|
||||
{
|
||||
@ -149,7 +146,7 @@ int Util::createXML(std::string filepath, uintmax_t chunk_size, std::string xml_
|
||||
fclose(infile);
|
||||
return res;
|
||||
}
|
||||
char rhash_result[rhash_get_hash_length(RHASH_MD5)];
|
||||
char rhash_result[rhash_get_hash_length(RHASH_MD5) + 1];
|
||||
|
||||
for (i = 0; i < chunks; i++) {
|
||||
uintmax_t range_begin = i*chunk_size;
|
||||
|
Loading…
Reference in New Issue
Block a user