Skip to content

Commit

Permalink
fixing shell code execution vulnerabilities
Browse files Browse the repository at this point in the history
Improve escapeSpecialCharacters to prevent arbitrary code execution
  • Loading branch information
nots1dd authored Jul 8, 2024
2 parents fb555c6 + 163d091 commit 3277d17
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions headers/src/lmus_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ string getFileNameFromInode(const string& inode) {
string escapeSpecialCharacters(const string& fileName) {
string escapedFileName;
for (char c : fileName) {
if (c == '$' || c == '#') {
escapedFileName += '\\'; // Add a backslash before special characters
}
escapedFileName += c;
if (c == '\'') {
escapedFileName += "'\"'\"'"; // Add a backslash before special characters
} else {
escapedFileName += c;
}
}
return escapedFileName;
}
Expand All @@ -82,7 +83,7 @@ void storeMetadataJSON(const string& inode, const string& fileName, json& artist
string escapedFileName = escapeSpecialCharacters(fileName);

// Construct the ffprobe command with the escaped filename
string metadataCmd = "ffprobe -v quiet -print_format json -show_format \"" + escapedFileName + "\"";
string metadataCmd = "ffprobe -v quiet -print_format json -show_format '" + escapedFileName + "'";
string metadataInfo = executeCommand(metadataCmd);

auto metadata = json::parse(metadataInfo);
Expand Down

0 comments on commit 3277d17

Please sign in to comment.