Skip to content

Commit

Permalink
fixes macos source url comparison, avoids sha256 of non existent files
Browse files Browse the repository at this point in the history
  • Loading branch information
zimbora committed May 27, 2024
1 parent 0594a8e commit f1031bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,11 @@ void Shutdown()
void Restart()
{
LogPrintf("%s: In progress..\n", __func__);
char exePath[PATH_MAX];


#ifdef _WIN32
if (GetModuleFileName(NULL, exePath, PATH_MAX) == 0) {
char exePath[MAX_PATH];
if (GetModuleFileName(NULL, exePath, MAX_PATH) == 0) {
LogPrintf("-Restart: Could not obtain the path for the executable: %s\n", strerror(GetLastError()));
return;
}
Expand All @@ -340,6 +341,7 @@ void Restart()
exit(0);

#else // Unix-like systems
char exePath[PATH_MAX];
ssize_t count = readlink("/proc/self/exe", exePath, PATH_MAX);

if (count == -1) {
Expand Down
6 changes: 3 additions & 3 deletions src/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ void CUpdate::ParseVersionRequest(json::value const& jv, std::string* indent){
std::string url = json::serialize(it->value().get_string());
url = RemoveQuotes(url);
#if defined(__APPLE__)
if( EndsWith(url, "MacOs-x64.zip") || EndsWith(url, "macos-x64.zip") )
if( EndsWith(url, "MacOS-x64.zip") || EndsWith(url, "macos-x64.zip") )
latest.url = url;
if( EndsWith(url, "SHA256SUMS-MacOs-x64.ASC") || EndsWith(url, "SHA256SUMS-macos-x64.ASC") )
if( EndsWith(url, "SHA256SUMS-MacOS-x64.ASC") || EndsWith(url, "SHA256SUMS-macos-x64.ASC") )
latest.sha256_url = url;
#elif defined(__linux__)
#if defined(__x86_64__) || defined(_M_X64)
Expand Down Expand Up @@ -314,7 +314,7 @@ int CUpdate::GetLatestVersion(){
std::string filename = appPath+"/"+pair.first;
if(IsValidSHA256(pair.second.c_str())){
hash = File_SHA256(filename);
if( hash != pair.second ){
if( hash != "" && hash != pair.second ){
LogPrintf("-Update: sha256 doesn't match file: %s\n", filename );
LogPrintf("-Update: calculated hash: %s\n", hash);
LogPrintf("-Update: source hash: %s\n", filehash[pair.second]);
Expand Down

0 comments on commit f1031bc

Please sign in to comment.