Terminal: fix possible buffer overflow

This commit is contained in:
李通洲
2024-07-22 09:22:01 +08:00
parent 3c9d9b3c67
commit 7f2ab7310a
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -262,10 +262,10 @@ static void detectFromWindowsTerminal(const FFstrbuf* terminalExe, FFTerminalFon
static bool queryKittyTerm(const char* query, FFstrbuf* res)
{
// https://github.com/fastfetch-cli/fastfetch/discussions/1030#discussioncomment-9845233
char buffer[64] = "";
char buffer[256] = "";
if (ffGetTerminalResponse(
query, // kitty-query-font_family;kitty-query-font_size
"\eP1+r%*[^=]=%64[^\e]\e\\", buffer) == NULL && *buffer)
"\eP1+r%*[^=]=%255[^\e]\e\\", buffer) == NULL)
{
// decode hex string
for (const char* p = buffer; p[0] && p[1]; p += 2)
+2 -2
View File
@@ -507,11 +507,11 @@ static bool getTerminalVersionZed(FFstrbuf* exe, FFstrbuf* version)
#ifndef _WIN32
static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version)
{
char versionHex[64] = "";
char versionHex[64];
// https://github.com/fastfetch-cli/fastfetch/discussions/1030#discussioncomment-9845233
if (ffGetTerminalResponse(
"\eP+q6b697474792d71756572792d76657273696f6e\e\\", // kitty-query-version
"\eP1+r%*[^=]=%64[^\e]\e\\\\", versionHex) == NULL && *versionHex)
"\eP1+r%*[^=]=%63[^\e]\e\\\\", versionHex) == NULL)
{
// decode hex string
for (const char* p = versionHex; p[0] && p[1]; p += 2)