diff --git a/src/fterm.cpp b/src/fterm.cpp index 53ed3558..c21da047 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -1002,10 +1002,10 @@ void FTerm::init() background_color_erase = false; x11_button_state = 0x03; - char* term_env = getenv(const_cast("TERM")); - if ( term_env ) - strncpy (termtype, term_env, sizeof(termtype) - 1); - else + + // Use format-string to import the untrusted environment variable + snprintf(termtype, sizeof(termtype), "%s", getenv("TERM")); + if ( strnlen(termtype, sizeof(termtype)-1) == 0 ) strncpy (termtype, const_cast("vt100"), 6); locale_xterm = getenv("XTERM_LOCALE");