From patchwork Fri Sep 11 10:37:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1362386 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23b; helo=mail-lj1-x23b.google.com; envelope-from=swupdate+bncbcxploxj6ikrb5ng5x5akgqefuwfizi@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=HhoCfrdT; dkim-atps=neutral Received: from mail-lj1-x23b.google.com (mail-lj1-x23b.google.com [IPv6:2a00:1450:4864:20::23b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bnsf42CgQz9sTp for ; Fri, 11 Sep 2020 20:37:47 +1000 (AEST) Received: by mail-lj1-x23b.google.com with SMTP id o13sf3407730ljp.18 for ; Fri, 11 Sep 2020 03:37:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1599820662; cv=pass; d=google.com; s=arc-20160816; b=PnHhSKRNshV87HeFOzez/VPi8eAHNANy6gSePHqd2we6WiOC/wXX4rZX+CMT5XTwcK RZyZXp8O6FRDaOYMCEjZxYCSrpJVQdhYQsp3BiK/g6AlUwJgoVFbQMfzr+b0pF7G/k0n 0FiP7Qr9yY+O/j0EAoXPxO+nBkOghHVagiYzpvStT3aXZrcm6whF/30iK4QYQ8E/+VWB jHKtRXPepcAY/tyukypVuLyID6XM2CRvpjjV6bGw5tB/9rIOiQeOiK+dEcdoUeTNhBCm V0mKbD1QNy7KvXA35ZgrHPEuSAmuU1uhZpRJAiiOxoizV73dkTwrh+Kr5VzNEuEMlt/U Bl9w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature; bh=ttSPGzCUeTMdPnlWvg5eKLVAvjRasLVgszq797jlePk=; b=xT3BnpIhHSH8/yEwcPfOeS0RHa1nU7ImNRztKeFBMlaW8g7SuM4ANSlnM3NxgpByCy 95mWEYlF6kpCHo1pfSDLZkeD/gMITjvQ3DH0+yZ54c832cwQKZCy8gvZ92MWvhGqS3LW YZ2aoeY71XzOOjMt5UKnNNrB+aFZncJStJj0tg2j2ay7QerAjC7m7KrZBw7aSl+YAN8b apcabhE2PMDC25pOOiZLW3ZxN7L7fxL+c9q+a/6ouY/4z68OKenpkzlKAP6OqVVwkgmo LICBvh/RSNBEepR7zCdjSYSBDQvX5uijCLI1rIvYWwhYuWt+QNKGKCzwS75KRxshEe0e A2DQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=ttSPGzCUeTMdPnlWvg5eKLVAvjRasLVgszq797jlePk=; b=HhoCfrdTMPSgyTWwMYIouKmdhphJ6XizGZYw9l+ytwmwjKEqqRhua4dMpXsI7VE67k 8BD89HfKlTwA53U5Gz+mnuWV0Qch3KSvi4t7BndrbFuZTrkuU1DVErN0fkf9LBVwXr3r zWEs9ON+ppdCAJ6908hk7Ed5hoq41BvnAa867CC4xsYYEfIkly/Lt9oBOttIqK9MIN5x Y/FCAmsyF76kQ45A+DtVp84MbpOXFQJs7xwzqvJj001Aured4gFcyq4SleNmetWlvqc4 99vrHbyVm0bcUxkUJdq1v5Yam8ghqMSHLmetockciBlMliFHBQnoUmVE2dwXJSnmXA4o 0fHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=ttSPGzCUeTMdPnlWvg5eKLVAvjRasLVgszq797jlePk=; b=J30S95NqzSmI12HkTu8kNM6HDR9NdqUYD0fE7wguRuUgllim0DVWi5Cz3s35uSq5mZ 8JC3+1mZgJY5TlqDm+Jyyc6RUXps+1bNyD5tpgHhhDngsUo3rpTXLK1hvfRF5fedzXCf BzGBXYPvURKveB1p23/L3yCQ6Te+4w5XysyS/iy4/cA27looKRGItpfDFZDkqIAPk9/S RqXCw/nF11CobTLhKxdEZZbPPdltNqPklIzSRWIlIyDaeLGVo6RcQWyYxU4kZ1uCJB2Z 1p0aJDgU+XjzJjDTCP8Cxx1xAMznOcu+Qwhu/ZhkDhpnhX68odcXxSKJj2N2EWT0gmne KhCQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531jOkHg91Gxu6ShtrRuLh7mRUMNLmjuqi2zCEnTuRF2WW6RwrLR QI2lECvnOrPT7royqI5Um2M= X-Google-Smtp-Source: ABdhPJwa9mdUXqgaxAi5qAZk6oJIjWhvMoFbx/LKvm0Ks+3SD345X/Lp3g5ZXHXmz0kqHmuS6HIQLw== X-Received: by 2002:a19:c6d4:: with SMTP id w203mr108409lff.245.1599820662098; Fri, 11 Sep 2020 03:37:42 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a19:6e4d:: with SMTP id q13ls550254lfk.1.gmail; Fri, 11 Sep 2020 03:37:40 -0700 (PDT) X-Received: by 2002:a19:ed13:: with SMTP id y19mr565243lfy.187.1599820660766; Fri, 11 Sep 2020 03:37:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599820660; cv=none; d=google.com; s=arc-20160816; b=d0XeHFZat7jtqy49R7dOm3iCrv9uBDzjwwAAreNH04IQYE5EFWahkbtzlD/P6Secyu q7RuTHvNed4ppkVvfFYobbGa52P5CVXhf2OwUHyHfKiU2X+k5u6vueOUg7QRgMPYyOPc bo6H31mW4klz2HE4OuJ5eUZ9AwN8tJ87vYg2dw90uqjp3IA/QPJsbM0bkHNkRCyN9TSG 5yb81gmn2Rb9wz6JYSj/f3SAK3k4pChWcjcut/wsYvE7a54K2KIjT56mfjMAOFeOrW2H SPmt49BUiHkvt0ij+NCK4OrrbWTBZEFkD9mQqwSIV1z9a8Vra4WfaWA4Ezs7Lmp4Dkyi hvtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=4ahftR0O6VuqsPnU2D+AJz78V3NPBTzfXom/okTFHSc=; b=BDo4aaH/fGPYXMw9eALfnPh7eMP9cVuCizN93Ds7aVxl+y5Xtc6/Z0J/6vNNB+J50f OW7p6xLk+ahkSYgS16elvj/XBcuLPNdC9HAzNo1F9UCXJQfZzhGWgUjLB20ldeIGjN63 rU522YyamwnBZUE6GTDysIxoaWaxe3M/ZLPa6XhTvo1AvGF1MFOSVTzsTOjuaYXZsloB 1GaGylEQlfJ6WnONrf8Qmhx1KU+pPILHvERJwO1dXXGHv+xTTPXF/PbbwHjT7va5SBmu r3gRGX3xEa9++Q/UFcJxiDUIu+/KdkNghrGtdXf3aSg4IFUvybZuOnuzQYYk66THWQqE TrpA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id y75si66267lfa.3.2020.09.11.03.37.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2020 03:37:40 -0700 (PDT) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Bnsdw1c9sz1qsbH; Fri, 11 Sep 2020 12:37:40 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Bnsdw1K1Vz1qqkw; Fri, 11 Sep 2020 12:37:40 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id Dl71eG7RimoL; Fri, 11 Sep 2020 12:37:39 +0200 (CEST) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Fri, 11 Sep 2020 12:37:39 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 315064540547; Fri, 11 Sep 2020 12:37:39 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6eIX9VjX62Gx; Fri, 11 Sep 2020 12:37:36 +0200 (CEST) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id AD0324540538; Fri, 11 Sep 2020 12:37:36 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH] lua: BUG in LuaStackDump causes SEGV Date: Fri, 11 Sep 2020 12:37:35 +0200 Message-Id: <20200911103735.147943-1-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Check if an entry on the Lua stack is really a table before trying to traverse it. Signed-off-by: Stefano Babic --- corelib/lua_interface.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index 2025942..192563b 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -76,6 +76,9 @@ static void lua_dump_table(lua_State *L, char *str, struct img_type *img, const /* Stack: table, ... */ lua_pushnil(L); /* Stack: nil, table, ... */ + if (!lua_istable(L, -2)) { + return; + } while (lua_next(L, -2)) { /* Stack: value, key, table, ... */ lua_pushvalue(L, -2); @@ -161,7 +164,7 @@ void LUAstackDump(lua_State *L) char *s; if (asprintf(&s, "(%d) [table ]", i) != ENOMEM_ASPRINTF) { - lua_pushvalue(L, -1); + lua_pushvalue(L, i); lua_dump_table(L, s, NULL, NULL); lua_pop(L, 1); free(s);