From patchwork Fri Feb 7 16:18:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Eggers X-Patchwork-Id: 1235066 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::53b; helo=mail-ed1-x53b.google.com; envelope-from=swupdate+bncbaabb5e363yqkgqewosqt3q@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arri.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=exlVbEkJ; dkim-atps=neutral Received: from mail-ed1-x53b.google.com (mail-ed1-x53b.google.com [IPv6:2a00:1450:4864:20::53b]) (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 48DgV46yCpz9sRK for ; Sat, 8 Feb 2020 03:19:07 +1100 (AEDT) Received: by mail-ed1-x53b.google.com with SMTP id bc3sf60493edb.15 for ; Fri, 07 Feb 2020 08:19:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1581092341; cv=pass; d=google.com; s=arc-20160816; b=he8Mu9KaZwr+dROGbWxRWSuRrk3roTisXGR7kPP4fpNQfswTQ3ob+3UtfqvxzgKR14 U7c26iBFbyUVFcQykKU8R59xsm6dHJ8f21lsiUv7XHrRdgMkq+iJ/GJSlfCS9/CRBKcN kU/4eX9t1l1l43LDD1aGkHS+MHNxt+FBTxqqososdNa8fA24hhd8+SzCmjwRlfWoDeQW yWLGpB5RpYiKNR6msL0OM6F5ki6HFNZPk5aGRxPD8mD6i5scgI2ZykAeQ0BLI3JT0lF5 S3meC+4zvEsPUuKIv9kvje1xavJvhuzQvnFlDq/6OxWpfjJ2cSBCRCyZDBoraEu+RzyL KqxQ== 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=HAQqp4h1fjxXBccQStkq714uIE1rQP3uSvzi6yIPUc4=; b=CWUxHYRCIJdV2pZ6FO3kdhaInhtghaRtbPJT+p7jlAdqCcLUw347L9czBe/3K2WKlI sI0dPz3/cU8vSGKob2ezSa+abR8l+PTpzmOoqGzmr/WZ3UPHKSEm0TIjcuGz6U8cbevx YJ4O1Hm2t2R5wCabeq7XvoMbn1qDPLQWmp3bQEuXMsGhYyXOE5t5g/Q/wjsgxs7KGXIs KWXTkmMV4gp2M1d6/9+DIeq4HgjSHNh4aoKA/vNCZymUSoWrMG0XgIX8c6QfCpBCVv+c XuDB6OJyaVM5+XuEK74oXsfzEXFKZNwwMx2ApP9oK4PSGJgE1Gz7pkexKSp1l4rlvMlu 0kpw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of ceggers@arri.de designates 94.199.88.101 as permitted sender) smtp.mailfrom=CEggers@arri.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=HAQqp4h1fjxXBccQStkq714uIE1rQP3uSvzi6yIPUc4=; b=exlVbEkJUPJzEoHujUkRRo3V4MVglkwGkwm70g6PyeVnenJazU5umKqisGnL9PQsct hizfkrZnZpPxwNoKgMRmeVfx8+wVDqQLmwQG1qkDdFJiDA4uIYNQHj0t1lFBUtdC02g0 fgeT52bxCkqJ2iQ1gSoO7XjmRryuXmLJhAXRhRIWwhYb158NslBnm0f/Zotpyc0dj2VK l7/BcbNTOskGWRvUofXe+yQKactfcvk41owWLY0sV1nw/uBpXxH4pBiX6YCUCr4TBppW k1sj08F935XplMlef+TZkV87dp4q4oE4KwHnUsz4hjULKT+4QG4f7CLBRaQiMldVSTKq z53A== 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=HAQqp4h1fjxXBccQStkq714uIE1rQP3uSvzi6yIPUc4=; b=rfbR244EaH7SQjK/+vuVORLLNSa/weX9ll0U5+I5tnM6BNfVtUn/FLTLaACB88Tqad 3ChtYwNThNiBL6D+1I+MlTCS6Dk3h7PzH/zAb0xwslcVypY9kgdgOfxivm69KOilOfpK KP3330/YqC4r719pytxyk5tQfqdHELxcQ9HCrN2rloR3n9tCN3/I4/CjMqAsJFq8OyQR iXwtP/JxaWsZTkzxD8elxfXQAQsaTdNFKK0k1kA6U9t0V5mbpCVLEgJvBUSx4dlj0MLw IHvT+M9yQyQ13e16LhtqrsHtDDdHT6WgTuHqKqYncmkUYgK4tiaB8KNQKsTLFsZaT8+5 j5Yg== Sender: swupdate@googlegroups.com X-Gm-Message-State: APjAAAWsQErLHzTgZbkNqYm6iao6PcmVzPch+wcyHUEudWiOGaqmKjwP Y9Gh00tWwK9M7dXuCS2LGqw= X-Google-Smtp-Source: APXvYqwYtKHpB83O1IEU3oUjf5DWdXa0hX/xkLZK2VhU87s4mqTxRDyjtbltJxxeJikXhy/0VBaI4g== X-Received: by 2002:aa7:d3d0:: with SMTP id o16mr8700837edr.102.1581092341146; Fri, 07 Feb 2020 08:19:01 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:906:bfe7:: with SMTP id vr7ls225771ejb.1.gmail; Fri, 07 Feb 2020 08:19:00 -0800 (PST) X-Received: by 2002:a17:906:3746:: with SMTP id e6mr7388ejc.165.1581092340490; Fri, 07 Feb 2020 08:19:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581092340; cv=none; d=google.com; s=arc-20160816; b=xjTXyRN3TJu12hNhaH7rYMieDrIwje1C9QCDCwO+N2sDLTEb+YcnKeua0h+693XeT+ xvKi8Ir7SA8eEAhqmrEImODjUOgk126eJr0qMJysrS9jbdKe0/TRJBdaLPJtdoVUEHKk 8x2ElfZFSR3U3v7IEMyB0YIMhSSMZxwaDI6OjMrTOhlkdcD9537OeWhQFrewW1g7o6le 1Tebo2DYTD6NaZDWpiua7laI7NI6xVwdJ5Pzgxz81CT+LwqNguOGLGX3gGqleF57oBHL pVZ+/8nn98w765RwWX/7yHw+KbWuhS01v4g2CqyDTr3oEWosxWwpNmEKgHe0G4WL3QF2 JHTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:message-id:date:subject:cc:to:from; bh=ekn/3snBO6jj+0KaiQg4YuIHCRxDancSeiNk/T78+t4=; b=eL9Uw40WJxR33RgxflDDkWUCBg4pWY734UbmT4dt7ZJI7QJ5v/aQy3h48g3kK1bL7e d76KOXDvDpSVrVSgMshlL6B0G1L/CH7dsTfmMB0FdCY/54YJeKnljNX8j3kGpMtdlPW6 N3LPFDaNfSP5rtDT+oy4FYo2xTvco6IlM864tNmrZhCJ0UhfogbrWexDmx9mUi3SKfKh q/TmQA64jfpNe93Q/JBFnLjFhlswi8rTeNgDkWxfuQQCIykHx5kcoIM3/6mI8N7842/U q/Vs//SQiQ9y+PJmDSVVMRDyCqDIjmwDR2s4fM4AvayHhW3zE6kwSSk687z7zI87VQtk yMTA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of ceggers@arri.de designates 94.199.88.101 as permitted sender) smtp.mailfrom=CEggers@arri.de Received: from mailout03.rmx.de (mailout03.rmx.de. [94.199.88.101]) by gmr-mx.google.com with ESMTPS id z20si1285ejx.1.2020.02.07.08.19.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Feb 2020 08:19:00 -0800 (PST) Received-SPF: pass (google.com: domain of ceggers@arri.de designates 94.199.88.101 as permitted sender) client-ip=94.199.88.101; Received: from kdin02.retarus.com (kdin02.dmz1.retloc [172.19.17.49]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout03.rmx.de (Postfix) with ESMTPS id 48DgTt3mrWzlkJ8 for ; Fri, 7 Feb 2020 17:18:58 +0100 (CET) Received: from ppmail.arri.de (unknown [217.111.95.7]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by kdin02.retarus.com (Postfix) with ESMTPS id 48DgTs5Vlmz2TSGr for ; Fri, 7 Feb 2020 17:18:57 +0100 (CET) Received: from mta.arri.de ([192.168.100.141]) by ppmail.arri.de over TLS secured channel with Microsoft SMTPSVC(7.0.6002.18264); Fri, 7 Feb 2020 17:18:27 +0100 Received: from N95HX1G2.arri.de (192.168.201.254) by mta.arri.de (192.168.100.104) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 7 Feb 2020 17:18:27 +0100 From: Christian Eggers To: CC: , Christian Eggers Subject: [swupdate] [PATCH] util: Fix memory leak Date: Fri, 7 Feb 2020 17:18:20 +0100 Message-ID: <20200207161820.20186-1-ceggers@arri.de> X-Mailer: git-send-email 2.16.4 MIME-Version: 1.0 X-Originating-IP: [192.168.201.254] X-OriginalArrivalTime: 07 Feb 2020 16:18:27.0411 (UTC) FILETIME=[3AA5C230:01D5DDD2] X-RMX-ID: 20200207-171857-48DgTs5Vlmz2TSGr-0@kdin02 X-RMX-SOURCE: 217.111.95.7 X-Original-Sender: ceggers@arri.de X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of ceggers@arri.de designates 94.199.88.101 as permitted sender) smtp.mailfrom=CEggers@arri.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: , Strings b1 and b2 were not freed if length check fails. Signed-off-by: Christian Eggers Acked-by: Stefano Babic --- core/util.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/util.c b/core/util.c index 3c6cde5..3c7db79 100644 --- a/core/util.c +++ b/core/util.c @@ -270,16 +270,20 @@ int get_hw_revision(struct hw_type *hw) if ((strlen(b1) > (SWUPDATE_GENERAL_STRING_SIZE) - 1) || (strlen(b2) > (SWUPDATE_GENERAL_STRING_SIZE - 1))) { ERROR("Board name or revision too long"); - return -1; + ret = -1; + goto out; } strncpy(hw->boardname, b1, sizeof(hw->boardname)); strncpy(hw->revision, b2, sizeof(hw->revision)); + ret = 0; + +out: free(b1); free(b2); - return 0; + return ret; } /**