Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp511377imu; Tue, 11 Dec 2018 03:04:17 -0800 (PST) X-Google-Smtp-Source: AFSGD/VeXfFX9JRl11d7gMFIOYW9eJMoNkvYtjYky5SIdWg/R7y+xRdtRnRtPbFLe4eqy1rSOO7D X-Received: by 2002:a17:902:ac8f:: with SMTP id h15mr15041323plr.245.1544526257096; Tue, 11 Dec 2018 03:04:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544526257; cv=none; d=google.com; s=arc-20160816; b=uFmp9XmDmnAUC3SZhY5RrCxbrK7Psxp9HABD7AhCwqq2Zp2gj5qPYRAp5Sa38kOgC1 DwAA29AoTFzBwArnX+U/J9emvnlpWgv+ACwKGNtbyzKwQiNelxFxCmvXm4NAFq3Azlwz qnAo2+mv+Sg4dbh1gLXHje63GHDsB1m7w3+oOEX62agu8qMWlzq2/pSovi8kZucF2Rd0 07yBjj0RSligr9MxYadRkmwQciyZZiYpAB5fIj+7Z1EoNeL6a2NNJeJnE86LcyypnQjK j0HDuReUmbNL9OsyaUHUvVEhPu6CjY85XFTAeSzoSkuePteiVQawGvZFZtnNJwsp8MdA tCYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=zSehz5sKi9aix5amSrmINjlwYVsoU6nXsGRPKh0lMLo=; b=sSKWPDy6sPQla08BBNWADsdwp6Qx0NrHdz0ncCStc9xOvcH9VGEsQjcODI8fSnAXAK /LMx7v0eSZ/iexhY4LWHiyQ4Br6NfiXLxwO1pOQkvO4ZULfe2G7mnPXSBJjG3JGHIkyF FDgJh/yiGYKEM7SoLn5Emer+UqG2PvzN7X/en6lRlVNgbowsIdvCLN9lskITc7xIjwEr STT+NDRyoHwHLWxJmCfm3PjKMLf52B6859bB9oER/31WKsOPG6cM2t21wnpdyBd4wuH6 uuSAIvX3cytfzdPzpy+IKs3fEW1qvlRhkhsz4kZ0A1nlyOqC2c6NBoIE+69wnEXUjFvp XhdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=p3CC9cwI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j91si12676740pld.395.2018.12.11.03.04.02; Tue, 11 Dec 2018 03:04:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=p3CC9cwI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726724AbeLKLBs (ORCPT + 99 others); Tue, 11 Dec 2018 06:01:48 -0500 Received: from conuserg-11.nifty.com ([210.131.2.78]:36709 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726601AbeLKLBo (ORCPT ); Tue, 11 Dec 2018 06:01:44 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id wBBB1C5d017210; Tue, 11 Dec 2018 20:01:14 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com wBBB1C5d017210 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1544526074; bh=zSehz5sKi9aix5amSrmINjlwYVsoU6nXsGRPKh0lMLo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p3CC9cwIqHRRCTrxDoVz7UVsAF5ni8sCGpeXSVsCaMb7fKKF/yga3871nqKxDOa4/ qToXkmvKntTs26LhMaSi46tBN+hOyqUF6UlJktpYkMGKqDdF/i3QhmdqQWUiMPiqui 1JBbB3XZ0OdXz7rARLFINBWFg0GriUxnI/49UUIdJp+xSFkp5w7WZV7B9cf8W3Gw8u 9m8m2ITJU3tmioLGXFjLYIQw2xDkIlu46VC6VnYJQG7LGOTZL4yeggPJkHhL0j+ica ZPMlN1DrpsE4lN04bQRI0n5Vv7sge295ax+unKo1EIH+UJttHubRmN/Z3KwP3QkPm/ AZP3gWXx+Nv/w== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Ulf Magnusson , linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 02/27] kconfig: fix memory leak when EOF is encountered in quotation Date: Tue, 11 Dec 2018 20:00:45 +0900 Message-Id: <1544526070-16690-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544526070-16690-1-git-send-email-yamada.masahiro@socionext.com> References: <1544526070-16690-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org An unterminated string literal followed by new line is passed to the parser (with "multi-line strings not supported" warning shown), then handled properly there. On the other hand, an unterminated string literal at end of file is never passed to the parser, then results in memory leak. [Test Code] ----------(Kconfig begin)---------- source "Kconfig.inc" config A bool "a" -----------(Kconfig end)----------- --------(Kconfig.inc begin)-------- config B bool "b\No new line at end of file ---------(Kconfig.inc end)--------- [Summary from Valgrind] Before the fix: LEAK SUMMARY: definitely lost: 16 bytes in 1 blocks ... After the fix: LEAK SUMMARY: definitely lost: 0 bytes in 0 blocks ... Eliminate the memory leak path by handling this case. Of course, such a Kconfig file is wrong already, so I will add an error message later. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.l | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index eeac64c..c2f577d 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -221,6 +221,8 @@ n [A-Za-z0-9_-] } <> { BEGIN(INITIAL); + yylval.string = text; + return T_WORD_QUOTE; } } -- 2.7.4