From patchwork Wed Apr 15 12:31:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1271121 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+bncbcxploxj6ikrbmp53p2akgqebmc3ney@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=tDuXOoAp; 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 492MDR5xkwz9sTy for ; Wed, 15 Apr 2020 22:31:50 +1000 (AEST) Received: by mail-lj1-x23b.google.com with SMTP id o21sf547881ljp.17 for ; Wed, 15 Apr 2020 05:31:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1586953906; cv=pass; d=google.com; s=arc-20160816; b=XfYUIRXi0tiOFH6XSguxnt4SbBINClX9ggUJPLNHLXXtnIvP3n5Y/FW9q4IV5FCx2s LoY16GlRdwuc9P17Nqqf4Bse3G9dUkJEHw4+ebDHIEEvkAyNCAOtQt8Qh1MqTogA5pD8 TyLfxOdW0dqW5hnIZpuryk6t8aUd9YZH9ZuqSg2QvGbRZFvJt7rdnZ1oX43I4lPA54dT pJHnWaKQJoYyjr1NRDJ4c6kEsSeo4/K1jo7x1mQYZvgYxr+8eBxiiujzKnz6A+eZu/br RdXgjqpUITVXAnonpzGnzKGabkt2NNijTYYwO6hNKINsuS3GVQOxLEmxSRBW9FYa0HvJ UmTQ== 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=gAfQmbf70OQAxuYxqjskPYjOJLjhzXSPjKXOt805v5I=; b=smx0gf0ANUi5d8vkdVPHi9yehiRuPOSZSCR7TkmeZtTncC7pDiYCOigbEMHyesn/ra lqdVkGrSVIrDXHaaGbD66VkK04W2+HxYKE6GNmt5LdXZt0VIuPMvPAuG537Xobs0ITL/ Z539C/5VzOofZSQEj6QSsdmHa/4bDlQitAOBaX5G2jF8Bj+Ol0mbpzXFo4QCeNi3CkAM x0ptrPlWy/ZuXp6cSfq3utUC1HgTCWZLf8aPBLS4YsOIztr2X+z7L/gViKJvy60kfIUW aSWajPYnG2B3srsnuILuffBVjR/36WM/z6Qj/gxWyA2+Ib/U2GtwFYb3/FcIGNETnMUi 8ELQ== 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=gAfQmbf70OQAxuYxqjskPYjOJLjhzXSPjKXOt805v5I=; b=tDuXOoApRrrG/z3uJNn5LmlsjCJHkgsV+wCkvHT2oOHjK7N7I+6ME8BKq3yfssGCqG phzvUeOk2fXUbYw7pSLdueO9d/B4s/3HipQOV1F5Rqr1H7Bsr8foQ4OP257S/RNBWasn /ILR33XXj8occU8E/+rHsvHPQDp4iZBFqMTEeS+s8M6+3sXbYsbxaOMwL9WK9qOnY92g 3M25iyleJQ4F5qMloJ8SvNY8tm/OY8M+VBNz4py0QjaPWYqUzHGNTcrifc6nJXSP4lve MX54Dars3emS26G9Kco7dpuSRdG5q7iBZPRrb3iLzl/+O9RpOxETT+CiCXBoqQbmA3jl XKNg== 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=gAfQmbf70OQAxuYxqjskPYjOJLjhzXSPjKXOt805v5I=; b=Vx0GoqUyLEAEDnTwCNxg1uRxMx9Gz+PkJdWp4EYMv9wlZOsSD/CmruhFJojI2qdLg3 F3TAYSbLhfRYGVoiI8IkOHZTvUBy9NizYq/oXNq4a/HWTCZzAy4t214LEDpzcKDZzJQu ZhsiV6RLFfGBsnNYrNb9d1AOthXWbtb2O/r5eldGK44gy27BC1TLcLxMKqpbnTIy9VWB YzWR5fKWiO1L1vcLRd6xjXidAS5udITNTkcBzR0fR7pzGa/5yVUq5QiG03UhCClHdlTI lee5wEyP+MKgzotyEuGKGtOMZ13am02nGOsHFVVqQbGtFjgaQQx/WfyCvDkFYGyUXdcM 1qgw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AGi0PuZ8cDHld9l9d37dTqUdqDyjJqdFZvjRjDW7SrtQqQGtAtSkOPiN wFSG0olJNmbx4j6ZMfRDzZk= X-Google-Smtp-Source: APiQypIqxrqcOaPNru5xxouv2vI6eQ+N5Cmwz0KSL1UQw5F3lTlQJrWxT8uLClOcFVHx2HxVZFLfsw== X-Received: by 2002:a2e:9ad9:: with SMTP id p25mr3213893ljj.39.1586953905661; Wed, 15 Apr 2020 05:31:45 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:b706:: with SMTP id j6ls1340628ljo.11.gmail; Wed, 15 Apr 2020 05:31:44 -0700 (PDT) X-Received: by 2002:a2e:3603:: with SMTP id d3mr3261434lja.82.1586953904777; Wed, 15 Apr 2020 05:31:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586953904; cv=none; d=google.com; s=arc-20160816; b=wjce9t0waY1k6IYCnStQE7pcgzTeEtt2snPK9fWeZ2k50fQFb6thM2pU3rN29+5Q8m wptJ03IXR+17uwwCxXIjW7TT0i5u5pjF+FGg1XkxAVvtsitmZpLphq1DSlKtFfh7gRf2 Kt5iZ1oF/Q13WNVLAkMhMfPifDlqnkauRL48GQfdOvrVFfD6swnpqKgVNFO9VX8Cho+O DL7cc1TBh2uWevfh3bHNn0/g79tI12Q9YwSQQFc4ooC8Kl4LO1kD0NBjM/ebSqVXm0lw 2l1P5DABc8ooiGDQFL371YqGb4z1/rVJWazvgzkkbRaf+tcyNwOBN23GYIm5cVE2N9/L w0Nw== 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=bRC3T2VANA7u33vATLFRI0sp+NQVcY266sUNO1H+5ZE=; b=QUllkSkqZnqO+eatHCY2tgmgZNH94+ttwLgJMcj9GRRP4Di5T8sUks4LYlMQtKujGT G09MAYvVP99SyPYOT0K/DU+6ZPANPG1BWHfYnol/R4xdliCVnSYBhlsKVHDi27GZbycr lMVUxuaCrSe6W8go7JPCnCnWXklLtT0gnQNj8ZBzfSYcWtvU0EBFrIBf7fK15ek6GVvv iVteOUbqFeaUIUMe8iRARIZI13januxhP1ch/zKxDDL7ICwhum4KAkT3a4wR3zh5BLIA DeF8Vy/csu7HDssjx0EG1rWQoSXTqCxV0NbrjcM5FKWvyIGQTJ9BpBFAEn2/Zh6IkxGA g0pw== 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 e4si240285ljn.1.2020.04.15.05.31.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Apr 2020 05:31:44 -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 492MDJ1lhMz1qsZy; Wed, 15 Apr 2020 14:31:44 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 492MDJ1XM2z1qqkT; Wed, 15 Apr 2020 14:31:44 +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 X_lKFFvDg-z0; Wed, 15 Apr 2020 14:31:43 +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; Wed, 15 Apr 2020 14:31:43 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 0FDB94540333; Wed, 15 Apr 2020 14:31:43 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 5OvwzXTy-Lng; Wed, 15 Apr 2020 14:31:40 +0200 (CEST) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.38]) by babic.homelinux.org (Postfix) with ESMTP id 0178D45403CF; Wed, 15 Apr 2020 14:31:39 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 1/2] Fix regression by introducing strlcpy Date: Wed, 15 Apr 2020 14:31:37 +0200 Message-Id: <20200415123138.17661-1-sbabic@denx.de> X-Mailer: git-send-email 2.20.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: , The implemented strlcpy is buggy, fixed it. Signed-off-by: Stefano Babic --- core/util.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/util.c b/core/util.c index 86057cf..0ed75ff 100644 --- a/core/util.c +++ b/core/util.c @@ -220,12 +220,17 @@ strlcpy(char *dst, const char * src, size_t size) { size_t len = strlen(src); + /* + * src is null termintaed, + * copy the last '\0', too. + */ if (len < size) { memcpy(dst, src, len + 1); } else if (len) { - memcpy(dst, src, len - 1); + /* truncate string */ + memcpy(dst, src, size - 1); /* Add C string terminator */ - dst[len - 1] = '\0'; + dst[size - 1] = '\0'; } return len; } From patchwork Wed Apr 15 12:31:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1271120 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::23e; helo=mail-lj1-x23e.google.com; envelope-from=swupdate+bncbcxploxj6ikrbmp53p2akgqebmc3ney@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=Uz0Us1+Y; dkim-atps=neutral Received: from mail-lj1-x23e.google.com (mail-lj1-x23e.google.com [IPv6:2a00:1450:4864:20::23e]) (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 492MDR5bDtz9sTR for ; Wed, 15 Apr 2020 22:31:50 +1000 (AEST) Received: by mail-lj1-x23e.google.com with SMTP id o13sf552326ljj.3 for ; Wed, 15 Apr 2020 05:31:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1586953906; cv=pass; d=google.com; s=arc-20160816; b=RHSnjETcJcrOkHUZ7Us9heQINXoBjqhoGLp/wiss0SVjHoGC8JK0KucP2r9DxH+DEr gfw5DvS5kk8/s0b0sy6Q/Zg/+FzLbxnulwGwadk11jaOTKyXC++xK4xBRFe1nKBvQSHg 1jI5rvU0Mg9VeMNeLNi+ypdnDsEBo09hBiAdOPQdjC7SrjI8ooiNvz1a6a3F+scLYgna qG507REaqUiT/BnlIusMGHmjAa2OcZWkO/asGERFVTzitAzuWuV0uLl6OpDUGINmvdxQ 4g+Vk2xkeXIu4DjCRs8YFXB7BhbMjgdX4ZRAhLhCUhv+XVw5vFnk7KI6DN+6zBYoakFX v1mQ== 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:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=8JxzKdE64HI6uo1SjRFLhk93fIQq9zR+mlqLt8qTNPI=; b=EgOcAR3uPd3XL4mnOmNQ2NsdSgpS4R9Dhl0TvqOJmZACJjWVSfkQCD7NqbF9vHq2m7 7wQjAhahd9sAiUIE/LbpKTTAa9UgZ1KBON7fgmK/7WA/L8dpQojbv03o5X2Kyq52jFdD FxOAPXqkiF0g0pis+ooOthZtIU0iIYBbVkYZM9DoIsn5Cs/Tk+OpYswpr1ErND9Kdwde cDAPUtBm1jxB5UCCvb+7Ua7uj1S3tmmohqhiugCFifVN+M1e0nXIsqjKkgTspcaUoTJk 48zR81uIRJ8j9rqizYN4n7Q7QDcaPoYZWnUFudoxJTOKfuznPnG5Pt2doBQ9lmNUAl7Y 7RgQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 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:in-reply-to:references :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=8JxzKdE64HI6uo1SjRFLhk93fIQq9zR+mlqLt8qTNPI=; b=Uz0Us1+YuleTl4lXKgoQEkGHs1al/2g8a4d/LuMunm982I7d4j4PIT2LrGWTdc1JrC tCkM07uRs7J3neyk46QbTgGHP3IebsumeEmwvetCRxjUGFizIDE6dV8YOE/Y9+kxXAvC iX9ga3qcWn1yrAxidWXZnEWXwEMbec0pMcCQBwrm7XeB+7VMvwqe5NB/tlb7PG83ORCk NGXrgaa4s9yoF/AAQk+aoAFRmCabQqay4IaMWgSKOZcj1Y5/BVk2tuKSkaQ79feDvJl2 QLnMBGCVyDbrHQS3e6LKrxW4g5OLc2lKW85Fa7gS7r1iP97j8nBZZ2KxKfCtIxNDm8NQ tuAA== 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 :in-reply-to:references: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=8JxzKdE64HI6uo1SjRFLhk93fIQq9zR+mlqLt8qTNPI=; b=umbxbggMFGKTI1rQ/FHGHc+HBnTeBjiIoJuZ1UJH3AB/I5MXd/WBTnmjMmZPGYyCwH l4gXNe3w2oumlnW1otQQ8KR1MZO77I+YSD2sXbGmK+c/gK18mvGQ4QwP1K4/2aGupnPC MXY2hEixU8sed4J+0n63yY9NB0aPIpVbkzvKo1+OjyuIS2CeS1u0jbl44cInETVZ/YYh T3ZrrgT2SSj3R2AlkW3bEaqC/rZAomgN5jajg1OP3qw8cpmxpVFlDUs4rP9xkmI3V6AY 6ZQbO6v6QeTr0HHCgnqIZI9inPw/4rIZo6wyKAzXB7KeXKj6VJQhHkVeGGFpz/uTS+k5 G+1w== Sender: swupdate@googlegroups.com X-Gm-Message-State: AGi0PuY4+fdiiMlIsksa89finDBeru9jbvV9S0sDW//Psrt225ji1ALT st2alV5zLepQuMCSO/ooxus= X-Google-Smtp-Source: APiQypIXCzSDH6QfqUUVb7tK937BN/BD7T6/J8hGx8Slunb4AnWe9HsDr1maQKSSkjaRFQklqV40GA== X-Received: by 2002:a2e:7602:: with SMTP id r2mr3032538ljc.184.1586953906046; Wed, 15 Apr 2020 05:31:46 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:b706:: with SMTP id j6ls1340635ljo.11.gmail; Wed, 15 Apr 2020 05:31:45 -0700 (PDT) X-Received: by 2002:a2e:9055:: with SMTP id n21mr3086094ljg.183.1586953905448; Wed, 15 Apr 2020 05:31:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586953905; cv=none; d=google.com; s=arc-20160816; b=xHf1iAoDGnFAaHDNaJM7PWvg4LBtnzthaM9DqTG/NIA1mWO7uABe0sTsWgsN52Vvvy 1F3yooxg6McYgJEaYMuW8ZK+Sjh9hic6TJKCTbEvBcpOJAuaDTA7ZTCCq/Eeq/K7Vs0J xg+ujExb7uHO81PvE+QWKqiQ1ToPOA9VlPfxQeN9io8K8LHNz+9EzSoLHP9esAkIe3vu kKy+dsYPBboEZcX5kPDycQJ0sEbfJ6RTQdRoD7DtoHQM34U9mET/Ynusli82w9tysm+X m5+yWA2JWgJWAgpccTpw4OgzBnm7Qz6SHTs/xn4/sFHQiKPLFJ/fwAEtwFujrPz3AqZz 6XSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=kgcCUFa9DbcyXWMZp00pH8hFpuAfaBP3PAuMForDlbM=; b=l4T6UP3LiPxlL04gTZy6kanimh67dlqNlBUmZUKSGWhqVls+sSInGXXhRGqHmH7/SY 43e1T7n0RsPRYnfoqeqpL6irYAzg07zabbuZIV5Yrvaa/yfXkZBwCKRCPfc88vLdya/B HJBR6KlsjJuKx6kBcEwR+Z4VLXXNvR6ccgrY10nA6qvUWt9DeMOuBeJ7n83PuRl7pW/B VskjO6rmclFVp8dFfLl6menX7iQ39O2P33WsOza3B7XiJ7HF1RKggcSYfcslFxbxWQ6l x6EXn8haHknxy62eFZ6eqtI0ZYBsjm9zQ+uq7Tdd/AVy2VoZ0WmbsAZNe2KxvsOZik/M OpnQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 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. [2001:a60:0:28:0:1:25:1]) by gmr-mx.google.com with ESMTPS id q24si74631ljg.4.2020.04.15.05.31.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Apr 2020 05:31:45 -0700 (PDT) Received-SPF: neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=2001:a60:0:28:0:1:25:1; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 492MDJ6QVBz1rtM9; Wed, 15 Apr 2020 14:31:44 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 492MDJ6DkYz1qqkX; Wed, 15 Apr 2020 14:31:44 +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 xBfLlVVNI0Fg; Wed, 15 Apr 2020 14:31:44 +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; Wed, 15 Apr 2020 14:31:44 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id B4F4545403CF; Wed, 15 Apr 2020 14:31:43 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id dC1-HxohoLUf; Wed, 15 Apr 2020 14:31:40 +0200 (CEST) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.38]) by babic.homelinux.org (Postfix) with ESMTP id 1F29D4540599; Wed, 15 Apr 2020 14:31:40 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 2/2] Regression: fix detecting selection Date: Wed, 15 Apr 2020 14:31:38 +0200 Message-Id: <20200415123138.17661-2-sbabic@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200415123138.17661-1-sbabic@denx.de> References: <20200415123138.17661-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 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: , This was detected after introducing strlcpy(). The seeltion string is copied without null terminating causing a wronf seletion to be taken. Signed-off-by: Stefano Babic --- core/swupdate.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/core/swupdate.c b/core/swupdate.c index 67e9b9d..1dc2053 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -406,17 +406,14 @@ static int install_from_file(char *fname, int check) static int parse_image_selector(const char *selector, struct swupdate_cfg *sw) { char *pos; - size_t len; pos = strchr(selector, ','); if (pos == NULL) return -EINVAL; - len = pos - selector; - if (len > sizeof(sw->software_set)) - len = sizeof(sw->software_set); + *pos = '\0'; - strlcpy(sw->software_set, selector, len); + strlcpy(sw->software_set, selector, sizeof(sw->software_set)); /* pos + 1 will either be NULL or valid text */ strlcpy(sw->running_mode, pos + 1, sizeof(sw->running_mode));