From patchwork Fri Jun 22 19:27:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Gouders X-Patchwork-Id: 10482877 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DE03B60230 for ; Fri, 22 Jun 2018 19:28:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2DAA28F63 for ; Fri, 22 Jun 2018 19:28:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B504D28F67; Fri, 22 Jun 2018 19:28:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=2.0 tests=BAYES_00, DKIM_ADSP_DISCARD, DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0F8F28F63 for ; Fri, 22 Jun 2018 19:28:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934096AbeFVT2K (ORCPT ); Fri, 22 Jun 2018 15:28:10 -0400 Received: from services.gouders.net ([141.101.32.176]:37687 "EHLO services.gouders.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933382AbeFVT2K (ORCPT ); Fri, 22 Jun 2018 15:28:10 -0400 Received: from lena.gouders.net (ipservice-047-071-023-039.pools.arcor-ip.net [47.71.23.39]) (authenticated bits=0) by services.gouders.net (8.14.8/8.14.8) with ESMTP id w5MJRqZE030825 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Fri, 22 Jun 2018 21:28:04 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gouders.net; s=gnet; t=1529695685; bh=xcA/UHtDzIAHtEQhyf/PnHqjGVbhLVV6AMeopdlz17A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DXlsdFE31hNTsgbIGrNQ9exEOIVLiK8JQAIInEwDtMuvkKwgnOoiQ8EQfwHpDIPuo JwY36PCv8od+JaCZaHraIi75ytOSF4Q1QkkSiWG+rWLBhtiDPe6XSM6pf6KEqXtTJi Z7qJ5Wj7sKXw6Pbzaprj5Fw+ERsk26CpbzvTzqzw= From: Dirk Gouders To: Masahiro Yamada , Linux Kbuild mailing list Cc: Dirk Gouders Subject: [PATCH 1/3] kconfig: avoid assert()-triggered segfaults in xfwrite() Date: Fri, 22 Jun 2018 21:27:37 +0200 Message-Id: <20180622192739.5327-2-dirk@gouders.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180622192739.5327-1-dirk@gouders.net> References: <20180622192739.5327-1-dirk@gouders.net> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP xfwrite uses assert() to ensure it does not operate on empty strings. Two users respect this, expr_print_file_helper() doesn't and causes segfaults e.g. when the dependency for an empty default string is printed. Fix this by calling xfwrite with an empty string pattern ("") for empty strings. INITRAMFS_SOURCE was one symbol that caused this problem, with this fix applied the zconfdump() output for this symbol looks as follows: ------------------------------------------------------------------------ config INITRAMFS_SOURCE string symbol INITRAMFS_SOURCE prompt "Initramfs source file(s)" if BLK_DEV_INITRD default "" if BLK_DEV_INITRD help This can be either a single cpio archive with a .cpio suffix or a space-separated list of directories and files for building the initramfs image. A cpio archive should contain a filesystem archive to be used as an initramfs image. Directories should contain a filesystem layout to be included in the initramfs image. Files should contain entries according to the format described by the "usr/gen_init_cpio" program in the kernel tree. When multiple directories and files are specified then the initramfs image will be the aggregate of all of them. See for more details. If you are not sure, leave it blank. ------------------------------------------------------------------------ Signed-off-by: Dirk Gouders --- scripts/kconfig/expr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index e1a39e90841d..e064bf4c2881 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -1231,7 +1231,10 @@ void expr_print(struct expr *e, static void expr_print_file_helper(void *data, struct symbol *sym, const char *str) { - xfwrite(str, strlen(str), 1, data); + if (*str != '\0') + xfwrite(str, strlen(str), 1, data); + else + xfwrite("\"\"", 2, 1, data); } void expr_fprint(struct expr *e, FILE *out)