From patchwork Thu Jan 25 18:57:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 866005 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:400c:c09::239; helo=mail-wm0-x239.google.com; envelope-from=swupdate+bncbcxploxj6ikrbd6rvdjqkgqeud3iuxa@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="h4EMpHja"; dkim-atps=neutral Received: from mail-wm0-x239.google.com (mail-wm0-x239.google.com [IPv6:2a00:1450:400c:c09::239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zSB9b71zYz9s7s for ; Fri, 26 Jan 2018 05:57:23 +1100 (AEDT) Received: by mail-wm0-x239.google.com with SMTP id c142sf4400833wmh.4 for ; Thu, 25 Jan 2018 10:57:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1516906639; cv=pass; d=google.com; s=arc-20160816; b=VLkGv+CC/WxubeuTEpfIwyQRNBwMq7SyS0t11ezkwXsBP8xxtLFTs07TNZKpfpMEQn kFEnoRyxkK+HRZD0vG/lksI1FOO7GyouA1zGBN3APCpS87dYjY7Gr1FbDJOJlwALEAtl CJ+yePq3ZwnzSbskzUemOxUjtcl5VLSIlDUlsCx4SP9M9YxAVGAhy1hxfNeb4fiyyZnO k2mIwZB6Ho9bul0L/r3n3SVyPWlmrFZX12n+yVjmdTCmzx5smmlAEsOVrkOJnzbAlB1k epreOz2kdOtPTfQ7OB9XB/ksOwr76h5EZmCn057TZEyVYZk2YIi3duLi7RRFTDQPi0Ew diMQ== 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=ODzrzzsISPsdshV6SfL4lwtCgI8qWF4vIkZGbaMQyxs=; b=nNVrPJE7NK6tT96ATpSBQafoXtGw3LgXMifG/GzuAWLeyt+vPYBqq86ffiQWqgCosl IeFEc03ekOq/2/v+MUPaigp79YJea1BR4Y++PDn9mcULqvWV5pdgFX31GmEr3mwkUqSN cm6wGlh7459j2jGO54xV3WY3HrpmfXW5AaFgop5Dtc2cYeneNRItUyGhF5UcckW/hUtA PTYkejgPhm1kJ0MP7dZlOylyqjZPezjjcK3Df4YBzf7kp8KRAhfeYvcyJwNEsEQhxl/M 7wmisaNtO5svgaTZ0qjTDwpURbNaipn90mgLU/3BVWwOdBa6RqGnO66ChVP8UCeNBk+n poSg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 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=ODzrzzsISPsdshV6SfL4lwtCgI8qWF4vIkZGbaMQyxs=; b=h4EMpHja94I0Vs3LtNAlWoMl6/ST59Z/UhD0PYfovZT+E4uwNZy8r9pf0xt9h6zidC FkEZ9v4fhY8l2zmgrJvuoph0Irxf2Y8zZfRwG+GK83U4zXWJ9uVmJ0nzmnY1s7HIcRPg hxhYUfrA0fIHl8I4sSyKwJb/+HXmcOxUlF4haDaTq+c4jvWV0bLcwFc1sgWHNOKqhahM 2ElHBxeY3xzEXIgq2wcnwQ/X9sKjkURTrc/8oaWsPjV4AaqvbU13ICZZeYn2tX6t2tVR CFPSCfNs7LSQdwrHajBjNKcObOl9LsL6PzfkDHw2kBWc6qfNHy6Ipns5Sf//c6Uv6FMi tPMg== 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=ODzrzzsISPsdshV6SfL4lwtCgI8qWF4vIkZGbaMQyxs=; b=axdcmTJkcaPQnkrp7KLgC+B6fysTfDE2yHNow36ywDPsJaX8XptqTnEQ0Fpy6ctiiO rpzHvczGwKrE/bvXvz61aPbU0f5WUk5Dq8cw/LKl5iqlW0XGviA5vipEp5dOFB0cVQqP yk1VoRnoCKBSPaVC4Wo7RxRUuV4VWHOLr1+TFsPt9zYgpES5egXtoO0fG1oxlZIdDAZp P9MCJHk6JdZy6/2rHp1Y53oeKmqPdPizWYXq0EEQxHOFwfSv3cYy843gkEqqz+si+Jo4 0twDGZXq0ZxrBQ37SvC10D1LPkJSuuTxy1Ae//yrT6oOkpwXLKxo6/fZfwdAXwyOJTFV zBYQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AKwxytcS8rcJQvRCp2YcvtREX66AG/VooSzmWOpyAqjAPgTicVUqR9BS i/EOTtlHBongf/nznUVdw+g= X-Google-Smtp-Source: AH8x2274MVQeDYfwfucQRSmoi2jSPjTqqn6aThCk3JrM/psHBfxqpMGTKlaMCwrNQtyPY0fbZsjbgA== X-Received: by 10.28.54.133 with SMTP id y5mr138955wmh.7.1516906639504; Thu, 25 Jan 2018 10:57:19 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.223.166.168 with SMTP id t37ls869174wrc.9.gmail; Thu, 25 Jan 2018 10:57:19 -0800 (PST) X-Received: by 10.28.192.26 with SMTP id q26mr1309748wmf.29.1516906638987; Thu, 25 Jan 2018 10:57:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516906638; cv=none; d=google.com; s=arc-20160816; b=QrkNjBHuP7A5J3YQwoZx4RfNEo2iNOijr2O3sRoru20p8b56jUdJV7o4P0vEQ2Vs35 yR5O3nQhdhF0U71gt9eDjeAro41p6bLeKoX20oKc+M4Sos1Pfwr7Jfl5LcNhzy33kTGu 5AD00goVQAA2j7O29sEyJRv+T8lVKjQjWV+lWYzi4X/YOc72RbXiPtqbpEkuosL5Mzsp 6isSdlUah33i3tqbHDE1qCQ5UkfYNx25mUs2VXYOcPkL9znn95MBMk1QCzr+xbVybEHE Vf1ABoTKmHk8knGwvtzyHFX5RfX2qh1N85t8izkYJabyJ/RJYOz6Zmi9LNTpEOkYZ/jZ bnrQ== 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=QmKupqHQUW8G5Pe66mJ5XgTUftc2EbhieLLf9LSGJjw=; b=LHe4pB4q/CgcugXFiFfY+vW88cwV+/8+nLnnpZmutmWW3wM6ofSvO/Lancqvq06ylx 0xBveRU7hcyVbj1IJ7ebNye0k1D9SU9kzhl+tFw7N8I9KgCoHIby0fPcEaiz1+jp8JGv MPWxy6ApL7f0eZViKc6sErqDR2XY2cPu2kYSr7gl318VFf1VFcf5cEwNKm6CviEVBjdi frmB8Y00KMHrQwm1kgmdywlX+J7qc8E6xZJz+YoPNa8c0BDZM/iaSD2qm1m6lmguqLks CMzO6b0XWDQytEkQ1ymEHN4i+jkMxpBnH+ZkDWcgEYr63PQJJAVp+pB/B2XXNQSV8/ej KvSw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 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.10]) by gmr-mx.google.com with ESMTPS id k21si672871wrd.1.2018.01.25.10.57.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jan 2018 10:57:18 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.10; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3zSB9V5fYZz1qsVV; Thu, 25 Jan 2018 19:57:18 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 3zSB9V5NhBz1t8nf; Thu, 25 Jan 2018 19:57:18 +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 xXINrej0xQjo; Thu, 25 Jan 2018 19:57:18 +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 19:57:18 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 9321345403A5; Thu, 25 Jan 2018 19:57:17 +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 98yAOafJTAik; Thu, 25 Jan 2018 19:57:15 +0100 (CET) Received: from papero.fritz.box (papero.fritz.box [192.168.178.132]) by babic.homelinux.org (Postfix) with ESMTP id 2CFDC4540378; Thu, 25 Jan 2018 19:57:15 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: aapril@kinova.ca, Stefano Babic Subject: [swupdate] [PATCH V2] swuforward: fix segmentation fault after changing dictionary Date: Thu, 25 Jan 2018 19:57:08 +0100 Message-Id: <1516906628-20335-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.10 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 Acked-by: Stefan Herbrechtsmeier --- Changes since V1: - use a variable to store the list returned by dict_get_list() handlers/swuforward_handler.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/handlers/swuforward_handler.c b/handlers/swuforward_handler.c index 8b0c17f..8f2c133 100644 --- a/handlers/swuforward_handler.c +++ b/handlers/swuforward_handler.c @@ -295,6 +295,7 @@ static int install_remote_swu(struct img_type *img, struct dict_list_elem *url; struct curl_slist *headerlist; CURLMsg *msg = NULL; + struct dict_list *urls; /* * A single SWU can contains encrypted artifacts, @@ -307,6 +308,16 @@ static int install_remote_swu(struct img_type *img, return -EINVAL; } + /* + * Check if there is a list of URLs where to forward + * the SWU + */ + urls = dict_get_list(&img->properties, "url"); + if (!urls) { + ERROR("SWU to be forwarded, but not remote URLs found "); + return -EINVAL; + } + /* Reset list of connections */ LIST_INIT(&priv.conns); @@ -320,7 +331,7 @@ static int install_remote_swu(struct img_type *img, priv.maxwaitms = MAX_WAIT_MS; priv.size = img->size; - LIST_FOREACH(url, dict_get_list(&img->properties, "url"), next) { + LIST_FOREACH(url, urls, next) { char curlheader[SWUPDATE_GENERAL_STRING_SIZE + strlen(CUSTOM_HEADER)]; conn = (struct curlconn *)calloc(1, sizeof(struct curlconn));