From patchwork Thu Jan 25 13:13:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 865891 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::23b; helo=mail-lf0-x23b.google.com; envelope-from=swupdate+bncbcxploxj6ikrb6fpu7jqkgqe32jt3tq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="DixKRShV"; dkim-atps=neutral Received: from mail-lf0-x23b.google.com (mail-lf0-x23b.google.com [IPv6:2a00:1450:4010:c07::23b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zS2Xq567rz9sNr for ; Fri, 26 Jan 2018 00:13:30 +1100 (AEDT) Received: by mail-lf0-x23b.google.com with SMTP id g76sf2147326lfg.1 for ; Thu, 25 Jan 2018 05:13:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1516886008; cv=pass; d=google.com; s=arc-20160816; b=GSBrfXlq9SHyBFni/+o8Aqzb8S8Xq7ofEV7E5FchMrpvotHQrtcpUuFom9u57IUcOB UuUA3hwJUQdTSHs2+Tk4nmHOxV9YlAZXibmmBYFzLAcEJH0wQG8NXPCjyLRyE4voEsH7 C4TI4x5K1jww2ERZ7AXDARbBvMxpMi1bFDofvQsH8B3utuNm2UJVncfAWQI2I+5JsxFw AtIzJWo+K55syx09vPEHbJs4CeXJy22qzMq+6IFUukh11Yzh5Db2HyXo3axHDC99nA84 AcJjluntgU3V0oUB6/Tgu5UIrBJXEAH4fhr2fbMRsDDjzNiootEB0puThCiP2yFBA+zU jBTA== 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=s4jc2OPyMiMvkAa0D8FspNCSsVuxD8BBzbcubr3vkUE=; b=VJIfasIbQVN3InpHfGBQ3LnTJAmL2aeLaKL39SSCxQNFWI+uBsOcAlTKzqEQAZPAzD STD0vwTBy4X7SpRDEez8qiamHVHoIfaZYXGv/CjMVl+E2GQOwKXFGbJeCZkX3xWKpXzL N1qLglAj3Ku+N61Xk8/S9gI/4V6WgcjfhFBut5kyPjz+5VhsdCW1ZiocC4W/CP9dqq/H USG4BrzPPSemz5H1Za0LXTYgXi+jG1DVAyaN7gIQR2poBsxpDJQI48QXGZfeZebQX4ix RgNxSsBfFNERiaJ3jvigAxENP6Pz4ItJDJzMq2kg6KEOSFpPYFo0uDxxH7FsP/WzEz7q +YdQ== 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: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=s4jc2OPyMiMvkAa0D8FspNCSsVuxD8BBzbcubr3vkUE=; b=DixKRShVj71XSwr8it76ucs1ATjlSZJdT1cYizRXwVr+U4RuY9I5kWyjMhw4yH6ij/ dqnK4CxkDqkzezGK2UuWhHZJjjTu6VSHvEughU6kUzDICXSGBbeH4+7GE3Ll9jDesa31 KZ1SGPHOWFZqRgPLqJ05JAZvSx3iZSCh1z1Man78phJCLrRDCQJAiq5c9MCQeFM6uPtV 8A9LpZXEkgXKe2PoNdcQOohjMWmX436xXonbYxoTgApM2Esyw+PQfTLoFrddj4FdeJvw Att5WSv2k5AhJmO1EDPnVGY06sYVuImRCFC+vryt1DY5XG2CyZUPNOgopKC2NF1aMUtl /V5A== 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=s4jc2OPyMiMvkAa0D8FspNCSsVuxD8BBzbcubr3vkUE=; b=kvFtnF3kTHqEVeov7V3hydj4CumUeASlxg9fgQtW08OyeaH2RAAJREDQ8kmZ97g+HE ZFv+DP02UGvd7qPf7+HJTMA2n3z1ILO8jsQlAx2iYDUQyr6h58KeR9bQLwXR0HxNzmCV mCVvg6eLmiXuC4vBSO7K/3kvEU2tapreNeuIWqXcMqiPOhsNcECQ+WZhzMmNUqUrAcxY SMFnT/99xrGUt2J29/sVDyQp3y/emzcpEH9wbSqgZdfp0OS+CltUkTwp3bfpA/oxITYb o35l+vqjXQlPxMGlZMZGpuXu+y9EEMlj6NW+4Mk4gPZcwt8USQ/lX1AcsHpIXjWfnZNy pRkA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AKwxytefveRkAbUiGvOOkkMfuXfIR5GgAXhsCrguZ7dhM4iJ8qLWJ64t HaCXwf1ezmEMoBHdkifTHYM= X-Google-Smtp-Source: AH8x2262vQwy4Q2pfD68lHjxBEyTODKjKYdC82VX5QsQox8464F8tJVyYOn+Sp8fFy/XeHjmllaoYA== X-Received: by 10.46.54.22 with SMTP id d22mr28573lja.0.1516886008437; Thu, 25 Jan 2018 05:13:28 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.25.123.4 with SMTP id w4ls1157428lfc.6.gmail; Thu, 25 Jan 2018 05:13:27 -0800 (PST) X-Received: by 10.25.18.85 with SMTP id h82mr919210lfi.4.1516886007813; Thu, 25 Jan 2018 05:13:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516886007; cv=none; d=google.com; s=arc-20160816; b=SzAqH7wsaXnK0aral004mK3ayjVR5fpALS/z8gktkg6EqdN4kFjTNCOIQqtZyrq+Uo rHLjrRRDiEynP+gFtL6Xf2WSuCs7BIf2Mx7zyrk6k0qHEiiBg2D1E1lwyx0fz/x3k8MI Nm746q7wftjOo4V0KOawYQOpBJ46QVten4EgZJVTWFdM76bIpXBP9+poYFvz4WpD7NCb dBafYvhyYG+l469oY1Acj+vi85NKfrcDqbEmT81vImFSdq/WylvTnOjhfdsmlTAezUHa i21ILDJcgYx4rmYpqyJp6I8YkjysqB/OUplb33XC0J2ZAnsVm3M4rG5Y5DXzSpCgiM/K z7rw== 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=6optpSxd7X5vt54GMflMALRtP6zIYeY7syYo/yp8BUE=; b=MQP/jOr/GWrKft3ApqMRffouOIHoRIN88xPRWo6q0zWv/szDe8I/TY+T0vb1Cdzbtj agEyEp6BYXm5AwZtEKRApilRQuPbG0nT2LPLZhprVGCKI4fMJCKnWo99BgVqfXGK704l wz14BNH7JAP1vp6tb8gGTki47zSA5UjGmXd0h6mX830POz5Vjw/8Tk378fwtYYjqRYQ/ U5P/iDC68n4HW10FJ3Vsw9f9YujCkXMbBCyhRhGbSF6TO/v85QDCrYfkN4bDTEpjGkFy vciO6AYebg++5ZZJMo4elMztn5GwdPOKeGXRJ+YRzUOSCk5IlZk4v7lZYWi95LHzizvh H5VQ== 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 y16si241930lje.2.2018.01.25.05.13.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jan 2018 05:13:27 -0800 (PST) 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 3zS2Xl2KnKz1r2RR; Thu, 25 Jan 2018 14:13:27 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 3zS2Xl1xfdz1t8ns; Thu, 25 Jan 2018 14:13:27 +0100 (CET) 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 Gno8F3cCrj96; Thu, 25 Jan 2018 14:13:25 +0100 (CET) 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; Thu, 25 Jan 2018 14:13:25 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id EB6FE45403A5; Thu, 25 Jan 2018 14:13:24 +0100 (CET) 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 bLigR4hFX_NN; Thu, 25 Jan 2018 14:13:22 +0100 (CET) Received: from papero.fritz.box (papero.fritz.box [192.168.178.132]) by babic.homelinux.org (Postfix) with ESMTP id 65B4C4540378; Thu, 25 Jan 2018 14:13:22 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: aapril@kinova.ca, Stefano Babic Subject: [swupdate] [PATCH] swuforward: fix segmentation fault after changing dictionary Date: Thu, 25 Jan 2018 14:13:18 +0100 Message-Id: <1516885998-17854-1-git-send-email-sbabic@denx.de> X-Mailer: git-send-email 2.7.4 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: , Recent commit d406032411bbced04e425f3a11c7f7f259443de0 changed the way to use dictionary. The function dict_get_list() returns a list if properties is found and the returned pointer must be checked before using it. Missing check causes a segfault in swuforward when URLs are not parsed. Signed-off-by: Stefano Babic Reported-by: Alexandre April --- handlers/swuforward_handler.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/handlers/swuforward_handler.c b/handlers/swuforward_handler.c index 8b0c17f..380f092 100644 --- a/handlers/swuforward_handler.c +++ b/handlers/swuforward_handler.c @@ -307,6 +307,15 @@ static int install_remote_swu(struct img_type *img, return -EINVAL; } + /* + * Check if there is a list of URLs where to forward + * the SWU + */ + if (!dict_get_list(&img->properties, "url")) { + ERROR("SWU to be forwarded, but not remote URLs found "); + return -EINVAL; + } + /* Reset list of connections */ LIST_INIT(&priv.conns);