Skip to content

Commit

Permalink
Verify 'exePath' length before comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
kelson42 committed Jan 5, 2025
1 parent ecca53b commit 853267c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ bool wasAppStartedFromARemoteDrive()
const std::string exePath = kiwix::getExecutablePath();

// Usual mounting point for Windows Network Drives
if ( exePath.substr(0, 2) == "\\\\" )
if ( exePath.length() >= 2 && exePath.substr(0, 2) == "\\\\" )
return true;

// Support macOS Parallels shared folders.
// See https://kb.parallels.com/130138
if ( exePath.substr(0, 7) == "C:\\Mac\\" )
if ( exePath.length() >= 7 && exePath.substr(0, 7) == "C:\\Mac\\" )
return true;

// Last chance to identify as remote drive
return GetDriveTypeA(exePath.substr(0, 3).c_str()) == DRIVE_REMOTE;
return exePath.length() >= 3 && GetDriveTypeA(exePath.substr(0, 3).c_str()) == DRIVE_REMOTE;
}
#endif

Expand Down

0 comments on commit 853267c

Please sign in to comment.