Skip to content

Commit

Permalink
Shell (Linux): remove version detection for unknown shells
Browse files Browse the repository at this point in the history
It's a dangerous operation. Should fix #1144
  • Loading branch information
CarterLi committed Aug 3, 2024
1 parent 0c82a84 commit d0b72c5
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions src/detection/terminalshell/terminalshell.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,28 +200,6 @@ static bool getShellVersionWinPowerShell(FFstrbuf* exe, FFstrbuf* version)
NULL
}) == NULL;
}
#else
static bool getShellVersionGeneric(FFstrbuf* exe, const char* exeName, FFstrbuf* version)
{
FF_STRBUF_AUTO_DESTROY command = ffStrbufCreate();
ffStrbufAppendS(&command, "printf \"%s\" \"$");
ffStrbufAppendTransformS(&command, exeName, toupper);
ffStrbufAppendS(&command, "_VERSION\"");

if (ffProcessAppendStdOut(version, (char* const[]) {
"env",
"-i",
exe->chars,
"-c",
command.chars,
NULL
}) != NULL)
return false;

ffStrbufSubstrBeforeFirstC(version, '(');
ffStrbufRemoveStrings(version, 2, (const char*[]) { "-release", "release" });
return true;
}
#endif

bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version)
Expand Down Expand Up @@ -261,9 +239,9 @@ bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version)
return getShellVersionWinPowerShell(exe, version);

return getFileVersion(exe->chars, version);
#else
return getShellVersionGeneric(exe, exeName, version);
#endif

return false;
}

FF_MAYBE_UNUSED static bool getTerminalVersionTermux(FFstrbuf* version)
Expand Down

0 comments on commit d0b72c5

Please sign in to comment.