Skip to content

Commit 7f2ab73

Browse files
committed
Terminal: fix possible buffer overflow
1 parent 3c9d9b3 commit 7f2ab73

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/detection/terminalfont/terminalfont.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,10 @@ static void detectFromWindowsTerminal(const FFstrbuf* terminalExe, FFTerminalFon
262262
static bool queryKittyTerm(const char* query, FFstrbuf* res)
263263
{
264264
// https://github.com/fastfetch-cli/fastfetch/discussions/1030#discussioncomment-9845233
265-
char buffer[64] = "";
265+
char buffer[256] = "";
266266
if (ffGetTerminalResponse(
267267
query, // kitty-query-font_family;kitty-query-font_size
268-
"\eP1+r%*[^=]=%64[^\e]\e\\", buffer) == NULL && *buffer)
268+
"\eP1+r%*[^=]=%255[^\e]\e\\", buffer) == NULL)
269269
{
270270
// decode hex string
271271
for (const char* p = buffer; p[0] && p[1]; p += 2)

src/detection/terminalshell/terminalshell.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,11 +507,11 @@ static bool getTerminalVersionZed(FFstrbuf* exe, FFstrbuf* version)
507507
#ifndef _WIN32
508508
static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version)
509509
{
510-
char versionHex[64] = "";
510+
char versionHex[64];
511511
// https://github.com/fastfetch-cli/fastfetch/discussions/1030#discussioncomment-9845233
512512
if (ffGetTerminalResponse(
513513
"\eP+q6b697474792d71756572792d76657273696f6e\e\\", // kitty-query-version
514-
"\eP1+r%*[^=]=%64[^\e]\e\\\\", versionHex) == NULL && *versionHex)
514+
"\eP1+r%*[^=]=%63[^\e]\e\\\\", versionHex) == NULL)
515515
{
516516
// decode hex string
517517
for (const char* p = versionHex; p[0] && p[1]; p += 2)

0 commit comments

Comments
 (0)