Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F0C54C4332F for ; Wed, 23 Nov 2022 07:11:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 68C108517B; Wed, 23 Nov 2022 08:10:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="i7zNQMDa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 35C0E854DE; Wed, 23 Nov 2022 08:10:57 +0100 (CET) Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 26A8B8517A for ; Wed, 23 Nov 2022 08:10:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilin.mikhail.ol@gmail.com Received: by mail-lj1-x230.google.com with SMTP id x21so20358420ljg.10 for ; Tue, 22 Nov 2022 23:10:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=BKOcHStld5ap8Iker4nzCi/iH8gThZA7rUic+HXRGYA=; b=i7zNQMDamrJKeIHMiKV0pT0aEv0r4LqMWMBKicAAnKpA1N4gQ3InHikmY3/c9LSN1c honGRUJSMT2QJNly/1SdPcwc316myIttHQFP5Th/Wy57lmjlT5IS8jl+nX6sY2ou9oHo j581vZDF2Zkgdp3ZrGomxnvyJ+R17lI2YA501xE2cYxaeudcmKeH5YFeawU/6wBe58+v faoB6aZmjrUrIHEk4ck3umn8zXSJ6N1hJchzPKYqFJWd0PneuXNr92DVSZG4IUf0r4Ex GZsyfToRAq3djXSsI3Mh8Ll6Yqe0bOtTkbf+Tv9hxHqFE9y0mbTUBIlkJNw/qnRyMQds whOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BKOcHStld5ap8Iker4nzCi/iH8gThZA7rUic+HXRGYA=; b=DDnX6RlyBiNIAfXxjXOTM6p3m+2+6TdAW/xMXdSlfrNhc3wboQbRbnNpONqppAV2Gx c815rHgAVafOKtZjCuUwlQfAT09BGA/CMTTTRVnDjDfYqQePWZb8I2p7inMy4CJKITuA vre6YZOQvqfch0qvLkyeJAz62ysxsusk9zGNOvawtRyKcWDuOEQbi/GourSrGZcbwYAP sABstbgQKy3mtxQbemAf1WCdJe2OQ4SkA29e7s1edOa/Q/eMk0U4g5VmIX/V5VugGBN8 VrcOt9naoA43gi16qNLYHqdBSBFPJzUl6QycUJ/6XM+gsvd/+nZM14jDsxxHTIV1v9hO aU/A== X-Gm-Message-State: ANoB5pmbx+wIwg1pOu5vrwhJOcrL77ybdAwBhzNhLCeikPOmuPBLUxbw jyHILq7HfPuQ95o/747+tq8= X-Google-Smtp-Source: AA0mqf7NZ5y4tMN77vdAXciJJRhMZBSlARFj0BrQijkflYF5R7Tsd13N7T40PfbtfKSwyS5txUm+jw== X-Received: by 2002:a05:651c:10bb:b0:279:737f:aeff with SMTP id k27-20020a05651c10bb00b00279737faeffmr1488292ljn.524.1669187454410; Tue, 22 Nov 2022 23:10:54 -0800 (PST) Received: from milin-wrk.rasu.local ([178.70.40.200]) by smtp.gmail.com with ESMTPSA id s12-20020a056512314c00b004b0317a1035sm2802862lfi.109.2022.11.22.23.10.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 23:10:53 -0800 (PST) From: Mikhail Ilin To: Simon Glass Cc: Mikhail Ilin , u-boot@lists.denx.de Subject: [PATCH v2] tools: mkimage: Fix nullptr at strchr() Date: Wed, 23 Nov 2022 10:10:21 +0300 Message-Id: <20221123071021.10286-1-ilin.mikhail.ol@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean The 'file' pointer can be null. Thus, before using it in the strchr() function, you need to make sure that it is not null. Fixes: d1be8f922eb3 ("mkimage: Fix variable length header support") Signed-off-by: Mikhail Ilin --- tools/mkimage.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/mkimage.c b/tools/mkimage.c index 5f51d2cc89..95005d8414 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -509,6 +509,8 @@ int main(int argc, char **argv) file = params.datafile; for (;;) { + if (!file) + break; char *sep = strchr(file, ':'); if (sep) { *sep = '\0'; -- 2.17.1