From patchwork Mon Jan 29 15:19:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 867157 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4010:c07::23f; helo=mail-lf0-x23f.google.com; envelope-from=swupdate+bncbdn7dbh5yqibbtpxxtjqkgqezypznty@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="Lq7eUAoc"; dkim-atps=neutral Received: from mail-lf0-x23f.google.com (mail-lf0-x23f.google.com [IPv6:2a00:1450:4010:c07::23f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zVY9s5Ztzz9s72 for ; Tue, 30 Jan 2018 02:20:48 +1100 (AEDT) Received: by mail-lf0-x23f.google.com with SMTP id r72sf2797142lfe.7 for ; Mon, 29 Jan 2018 07:20:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1517239245; cv=pass; d=google.com; s=arc-20160816; b=dhJBcM4oe8kVPpRNFHPiBhVKNQKOYFfiSpnN3WaT7fEfzCs6m9P1RR1Asf+3WYNpcz Gj2P+GzRvNbmj+SggNTkanx5IcZ8KWtG6exXtAcVX5Xr2tZt2KKc68juFKWR0VkilHlR LB+zsgL9xp+5gYMQxRVEUP+TMsKA8xEqqPdbDVJPgQ8+Nqw1zHZ37kud+QnLyLXCkHgA elp6FsRMpgKIKEIKyNuzsoXWoDRljoJPdV8+7vP/LOHMo3DC8ZZOlHrrDE67ntIJSOXA RTKDU+PsUguoV9FDoV0ebYuK/eTG2/ZBGHafLE4y3xG3W7+dpO5D1HsnUWsyTFAv7S5C RJsQ== 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:message-id:date:subject:cc:to:from :arc-authentication-results:arc-message-signature:mime-version :sender:dkim-signature:arc-authentication-results; bh=2oRYRzVMbpn7y3G206A0LSViuJOnAKAoGHj54CTE+p4=; b=fNg1qcJcsrQ5cA2JFTQqh+20RLkuyte4E6Oke2/j+vrEfnqV7wIi102Hsg149LRsTG WWIHdqwADn/4mRQ6ftWtkYFFIji9PvFOf1jwXsKPBXn/anEf4OSK9JDG6O18iIxsXtPF Zk8P9+SwrrbDh6gJLwZYLhLdxbNN+g/My4IWn4lbOsFRRykByG9RvBu5iqlYvBfVBGKG 7ezhj41qWmqsXRF4xEZWDFxBcxIVDXjeCOCrb2m7Fj+b0etc2vJp4GCzYOhkhlF0KbBR R7vdCFV79H2bM/4jgE1ifmkYVMZ87TNZkhMH3KQxnMRC8r1WztuXgTTaLMg/bR8wvKQj 0Q8A== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 85.13.157.12 is neither permitted nor denied by best guess record for domain of stefan@herbrechtsmeier.net) smtp.mailfrom=stefan@herbrechtsmeier.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=2oRYRzVMbpn7y3G206A0LSViuJOnAKAoGHj54CTE+p4=; b=Lq7eUAocFG66msC/z/m4VwbIoW/iwYdUvg8ke05JQkQv4hS3KM258SGZm67T1t3W6o +2cNhPhCcfSd1yljI72dyNl1yYwoEytX3qfc10asia6UNT7nQGAtrCej9jYdGbYYuZKU eWMHlaiih/fFuMd2omjDydwUAstemFs8jMMMSl//0sBCGl3oH0WsUwzHm3Py9DNYuLLm L/Z7ggq6VuxCawfHr4cojOxMIIYZabycdhOQu69cYmkDCxWl32RwgjPcGarecLbGj+s3 NQsKxC+qJcEXgWtpIUDt09zi5bLaasgu8VSNRV86GV0eQkpySIfImKlW7OeIgxHoGn/Z bJ0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id: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=2oRYRzVMbpn7y3G206A0LSViuJOnAKAoGHj54CTE+p4=; b=Qopt3gPz2PBbZu006IPPBRkvUsTvTYLGcZR+yBirc1ssc7fm83+CeIB7GE32fBH7IC c00zLGx/1axjq577L2LLBfjlqB+HXGgebmRUvQt9Lbw0wIeMweiuFyh+RaZ85VB16mxC N/I2qQ7TQmv/w25HSO7kmFsDwDfg6AMZ2eLfOql+BtpDuHHvTec509EY2h56uPJ+rG2D AdjyCY85+YSZCXx3t3aDQ0toARiE1otbrI0XNAyZElLCbuus2q4+Et7ZWB1XQOyLkFZn 2vqkuxAH/7BRcDG62DQOHfpTrb45GtgUebfVMOCoo0VA6DPWQxnrKsspCVXrMr2X1gPY AQtg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AKwxyteo8CzaFRWjSNpmQzlRjSM0pnbJEqHtrOFPBcOJe3W5FPkHl0j9 VzvR3wXwR4lzbYE62rz+oRg= X-Google-Smtp-Source: AH8x2240bDb+4TrcaZIyxISjzoqzblKqZTORiVJVEOqf5J7bsGt6FLvSihfPEf91Mbo+lGJl+dKTfg== X-Received: by 10.46.9.148 with SMTP id 142mr63778ljj.2.1517239245710; Mon, 29 Jan 2018 07:20:45 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.25.92.150 with SMTP id u22ls76081lfi.2.gmail; Mon, 29 Jan 2018 07:20:44 -0800 (PST) X-Received: by 10.46.77.193 with SMTP id c62mr132539ljd.32.1517239244955; Mon, 29 Jan 2018 07:20:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517239244; cv=none; d=google.com; s=arc-20160816; b=v+rRFJIgSqm7g34ybyG+GK7jKcG6vGYOfPpCndFD39jlApY5Oxxac08yAsYjSaNREG n8vSlt78LSrAtC0ixatw0Ex8NZ1j2TFHHC4bsSG26nZIfFwgoNnSM960bUJYz4dgzhCJ gS2equ3O93zlJzT1vddECgwEAeNc14My5m8Be8IZE4YWdAIJwLCVcpun2hHjmJcEn0cA 25x1wVH1x44Psz/JxiPv3bhgFLYXrwDIwUP6qpYgaTGj/tlqf3N95JBEgUXuH5L+UyGr NEDyI1QPQBSIKDuLUD305VA7GtHK4ytA1MKVc/6+J+JyVqxlZXiZUE5PkGMLl5PQB0qt HfkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=jCd2WwI/IgCUCqQJ0FvDpQI18hLluTf2W7l6ntSpD6w=; b=sK5JR4q/z8qTKUNdeB7af8LUyPrqGudOonTuml2ztg7EtQFoMQMNvTypy4ym/6nk4f BJL4YFdV3HBqNdMhArf4vnW8PiQVpyr616Hogr2+Pa4NCLM/WEk/Qa7GnWjnjdMHvfSl jK3BtX3xg0KpbxIbudJz1V7AClqv+DFKk2hlsl0h86XYat0p2YsRyBcqb8EjQS+64tSu kX1WmkURmJ0KjhMqqiGkBCb2f043A0lAlJPh+c82gWV/E2Q635bfLbSRAndyGAWylYZe GdsUDP0lqfKvfqIcKQJdxI89/XifBLSnuHeVXHBADXyZ5x3VvCPnK0UtRYOf+MyC/no7 eogw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 85.13.157.12 is neither permitted nor denied by best guess record for domain of stefan@herbrechtsmeier.net) smtp.mailfrom=stefan@herbrechtsmeier.net Received: from dd41138.kasserver.com (dd41138.kasserver.com. [85.13.157.12]) by gmr-mx.google.com with ESMTPS id w29si1411641lfc.5.2018.01.29.07.20.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jan 2018 07:20:44 -0800 (PST) Received-SPF: neutral (google.com: 85.13.157.12 is neither permitted nor denied by best guess record for domain of stefan@herbrechtsmeier.net) client-ip=85.13.157.12; Received: from WS08941.weidmueller.com (unknown [217.244.7.16]) by dd41138.kasserver.com (Postfix) with ESMTPSA id 2862A11A007A; Mon, 29 Jan 2018 16:20:44 +0100 (CET) From: stefan@herbrechtsmeier.net To: swupdate@googlegroups.com Cc: Stefan Herbrechtsmeier Subject: [swupdate] [PATCH v2] Lua: Null check return value of luaL_checkstring functions Date: Mon, 29 Jan 2018 16:19:35 +0100 Message-Id: <1517239175-18678-1-git-send-email-stefan@herbrechtsmeier.net> X-Mailer: git-send-email 2.7.4 X-Original-Sender: stefan@herbrechtsmeier.net X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 85.13.157.12 is neither permitted nor denied by best guess record for domain of stefan@herbrechtsmeier.net) smtp.mailfrom=stefan@herbrechtsmeier.net 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: , From: Stefan Herbrechtsmeier Signed-off-by: Stefan Herbrechtsmeier Reviewed-by: Stefano Babic --- Changes in v2: - Correct null check of name variable inside l_get_bootenv and l_set_bootenv function corelib/lua_interface.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index 78c4df4..ed0849a 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -614,7 +614,7 @@ static int l_notify (lua_State *L) { lua_Number error = luaL_checknumber (L, 2); const char *msg = luaL_checkstring (L, 3); - if (strlen(msg)) + if (msg && strlen(msg)) notify((RECOVERY_STATUS)status, (int)error, INFOLEVEL, msg); lua_pop(L, 3); @@ -624,7 +624,7 @@ static int l_notify (lua_State *L) { static int l_trace(lua_State *L) { const char *msg = luaL_checkstring (L, 1); - if (strlen(msg)) + if (msg && strlen(msg)) TRACE("%s", msg); lua_pop(L, 1); @@ -634,7 +634,7 @@ static int l_trace(lua_State *L) { static int l_error(lua_State *L) { const char *msg = luaL_checkstring (L, 1); - if (strlen(msg)) + if (msg && strlen(msg)) ERROR("%s", msg); lua_pop(L, 1); @@ -644,7 +644,7 @@ static int l_error(lua_State *L) { static int l_info(lua_State *L) { const char *msg = luaL_checkstring (L, 1); - if (strlen(msg)) + if (msg && strlen(msg)) INFO("%s", msg); lua_pop(L, 1); @@ -721,7 +721,7 @@ static int l_get_bootenv(lua_State *L) { const char *name = luaL_checkstring(L, 1); char *value = NULL; - if (strlen(name)) + if (name && strlen(name)) value = bootloader_env_get(name); lua_pop(L, 1); @@ -736,8 +736,8 @@ static int l_set_bootenv(lua_State *L) { const char *name = luaL_checkstring(L, 1); const char *value = luaL_checkstring(L, 2); - if (strlen(name)) - dict_set_value(bootenv, name, value); + if (name && strlen(name)) + dict_set_value(bootenv, name, value ? value : ""); lua_pop(L, 2); return 0;