From patchwork Fri Jun 12 15:23:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu \(Google\)" X-Patchwork-Id: 224561 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24FEFC433E0 for ; Fri, 12 Jun 2020 15:23:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E74BB20888 for ; Fri, 12 Jun 2020 15:23:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591975411; bh=x6ui656WX28sE3Yvb4xU6w8S45iyxh69N3Y0uxLKS3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=G/EBJLG600ZfYxB3UtkA2KE8PnUjVEWUgIU412hJpf2BV/BJoOjW7MKnlBiL65cul NdvauDeok0QgCx+Xgs4MLaoWjPvXDZi6GEr68v80rA6NHgkYiCJbAubIKY9Xps45MJ 5Y05Hb9TKCG7ieWgmQ+2xuf7EGmh5nopjDjzostE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726610AbgFLPXa (ORCPT ); Fri, 12 Jun 2020 11:23:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:43262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726272AbgFLPXa (ORCPT ); Fri, 12 Jun 2020 11:23:30 -0400 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ED9C120884; Fri, 12 Jun 2020 15:23:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591975409; bh=x6ui656WX28sE3Yvb4xU6w8S45iyxh69N3Y0uxLKS3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CQMwxd2hRK36sigCosK3YhQYeuFn1urJ9k8og8NCjgeXFqHjX3yoLaqpPbw++40Ia uXbYNqNxxpXWi8Kk0DgWxt4VUc/TzcQgcgs3c5zH9go9nfWl39zjh8oyi5Jml0ICea FM1uE4AU4YwijPhiWKkSEBJAQrPPKyG73fScPn0M= From: Masami Hiramatsu To: Steven Rostedt Cc: stable@vger.kernel.org, LKML Subject: [PATCH 2/4] tools/bootconfig: Fix to use correct quotes for value Date: Sat, 13 Jun 2020 00:23:26 +0900 Message-Id: <159197540663.80267.14460253938950080887.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <159197538852.80267.10091816844311950396.stgit@devnote2> References: <159197538852.80267.10091816844311950396.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Fix bootconfig tool to show the correctly choose the double or single quotes according to the value. If a bootconfig value includes a double quote character, we must use single-quotes to quote that value. Fixes: 950313ebf79c ("tools: bootconfig: Add bootconfig command") Cc: stable@vger.kernel.org Signed-off-by: Masami Hiramatsu --- tools/bootconfig/main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c index 0efaf45f7367..21896a6675fd 100644 --- a/tools/bootconfig/main.c +++ b/tools/bootconfig/main.c @@ -14,13 +14,18 @@ #include #include -static int xbc_show_array(struct xbc_node *node) +static int xbc_show_value(struct xbc_node *node) { const char *val; + char q; int i = 0; xbc_array_for_each_value(node, val) { - printf("\"%s\"%s", val, node->next ? ", " : ";\n"); + if (strchr(val, '"')) + q = '\''; + else + q = '"'; + printf("%c%s%c%s", q, val, q, node->next ? ", " : ";\n"); i++; } return i; @@ -48,10 +53,7 @@ static void xbc_show_compact_tree(void) continue; } else if (cnode && xbc_node_is_value(cnode)) { printf("%s = ", xbc_node_get_data(node)); - if (cnode->next) - xbc_show_array(cnode); - else - printf("\"%s\";\n", xbc_node_get_data(cnode)); + xbc_show_value(cnode); } else { printf("%s;\n", xbc_node_get_data(node)); } From patchwork Fri Jun 12 15:23:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu \(Google\)" X-Patchwork-Id: 224560 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 265E6C433E1 for ; Fri, 12 Jun 2020 15:23:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 043EB20835 for ; Fri, 12 Jun 2020 15:23:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591975430; bh=F7Sl8iF2HTDHLNCSmKnG6INFrp4GW1T2ClUzszWv0Hc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=toL2/FhyCdzrudHDf0Wbtm3fult1MSEjRT3w1W7K8a+kOoxipv04JJ3j/1hUMkp8l yiaOUKwExATa9nLPHQO7U0B0xBhm8R3ttAvKMO1j1Ia/F8F0NdIk31aJsK1W+EdMeB jqspqBihGLrf2DZn4aMCnhLl3+Yj5lx8soqquzgg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726675AbgFLPXs (ORCPT ); Fri, 12 Jun 2020 11:23:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:43604 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726272AbgFLPXs (ORCPT ); Fri, 12 Jun 2020 11:23:48 -0400 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A856D208A7; Fri, 12 Jun 2020 15:23:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591975427; bh=F7Sl8iF2HTDHLNCSmKnG6INFrp4GW1T2ClUzszWv0Hc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OBfj/db/kfzFyhv298soYPbeeGayEf/yp4Z+U2fS5JXrr/TzpGLoih2B0ni0x3Lm4 9MChV0JKHvMu1OqB2z+5dLCKEa5vcEc5sIOWNHJ22j+D5e6kF9E5VLfkgyWASBG3Vn k12p3sXB4phjAjGvoh4UNl+buZD6KZ81GnirL44g= From: Masami Hiramatsu To: Steven Rostedt Cc: stable@vger.kernel.org, LKML Subject: [PATCH 4/4] tools/bootconfig: Add testcase for show-command and quotes test Date: Sat, 13 Jun 2020 00:23:44 +0900 Message-Id: <159197542404.80267.8469678731615218528.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <159197538852.80267.10091816844311950396.stgit@devnote2> References: <159197538852.80267.10091816844311950396.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Add testcases for applied bootconfig showing command and double/single quotes issues. Signed-off-by: Masami Hiramatsu --- tools/bootconfig/test-bootconfig.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/bootconfig/test-bootconfig.sh b/tools/bootconfig/test-bootconfig.sh index eff16b77d5eb..3c2ab9e75730 100755 --- a/tools/bootconfig/test-bootconfig.sh +++ b/tools/bootconfig/test-bootconfig.sh @@ -55,6 +55,9 @@ echo "Apply command test" xpass $BOOTCONF -a $TEMPCONF $INITRD new_size=$(stat -c %s $INITRD) +echo "Show command test" +xpass $BOOTCONF $INITRD + echo "File size check" xpass test $new_size -eq $(expr $bconf_size + $initrd_size + 9 + 12) @@ -114,6 +117,13 @@ xpass grep -q "bar" $OUTFILE xpass grep -q "baz" $OUTFILE xpass grep -q "qux" $OUTFILE +echo "Double/single quotes test" +echo "key = '\"string\"';" > $TEMPCONF +$BOOTCONF -a $TEMPCONF $INITRD +$BOOTCONF $INITRD > $TEMPCONF +cat $TEMPCONF +xpass grep \'\"string\"\' $TEMPCONF + echo "=== expected failure cases ===" for i in samples/bad-* ; do xfail $BOOTCONF -a $i $INITRD