kconfig: qconf: fix buffer overflow in debug links
authorMasahiro Yamada <masahiroy@kernel.org>
Tue, 1 Oct 2024 09:02:22 +0000 (18:02 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Wed, 2 Oct 2024 07:02:40 +0000 (16:02 +0900)
If you enable "Option -> Show Debug Info" and click a link, the program
terminates with the following error:

    *** buffer overflow detected ***: terminated

The buffer overflow is caused by the following line:

    strcat(data, "$");

The buffer needs one more byte to accommodate the additional character.

Fixes: c4f7398bee9c ("kconfig: qconf: make debug links work again")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/kconfig/qconf.cc

index 7dba8014ead4d75ca159505ffbc1faeaefb44447..e260cab1c2afff347aa6e8d773c6058f11a3a7b6 100644 (file)
@@ -1166,7 +1166,7 @@ void ConfigInfoView::clicked(const QUrl &url)
 {
        QByteArray str = url.toEncoded();
        const std::size_t count = str.size();
-       char *data = new char[count + 1];
+       char *data = new char[count + 2];  // '$' + '\0'
        struct symbol **result;
        struct menu *m = NULL;