From patchwork Thu Apr 16 19:14:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1271870 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::438; helo=mail-wr1-x438.google.com; envelope-from=swupdate+bncbcxploxj6ikrbaw54l2akgqernlzuda@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=pjO/jQl0; dkim-atps=neutral Received: from mail-wr1-x438.google.com (mail-wr1-x438.google.com [IPv6:2a00:1450:4864:20::438]) (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 49386F5FgLz9sSd for ; Fri, 17 Apr 2020 05:14:13 +1000 (AEST) Received: by mail-wr1-x438.google.com with SMTP id j16sf2216583wrw.20 for ; Thu, 16 Apr 2020 12:14:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587064450; cv=pass; d=google.com; s=arc-20160816; b=CiWQpEemoLc3ZWoWYX82HZY8nfWo9GOOzChM/6rkWc7CEC5kYMxKCS4+LAnCXEmyqD I2PJTbZyaHnQAd7DYvOW06Bxu9bUUNnSkXLALX/PjS8/ZFMFkoj6C2A7yCLwvbe8GxJu 2vAQgvo7RVRBwHPt58KgFXB4vd6AUjK7XoJx2xY10Y50deMkXbjKEtaSj7n9xpsSdH02 ZcYTq97Jp+RIjQF7E06ZNKJB8K10RvCnGVnlN4upiUlS273gFnGl5uZ5IqiM6gNOn1/y +351F5FTOoLiAfmwSQMzae1wtKdgM/l0QFMGmB97VhYofvqCIHQlmHE0N9Ke8uRC0imY 5kzg== 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=gQMzr2V1uRmYi+UxjrCSQBKLILw5jZ6kFg3CmC13PYw=; b=JF3qPHm4lbYz9f4FLl6uY95wq5kGZR7brfzRB6S0dvSFy7BKUBFkDTQmXz5NA8vAli ghZSq2vga6hMCanKUhjufwPXH+goZTlL7fr3T/O1pP0wy2MS+9P8AEZX3YcvCS8dpcvP yYbJspCL4jHVBjrXTkmCw9QCv2S3YJ9YYJxik6GRSXuBTOVPDAaCHg920M1UrS+PXDni PEFmpfG+fjo6FBP6vSGucLQNZKIVlYcsXtP3ctoIwGFQv2hsxY7AdexgC3PYUPgnCjtD sxZ5pX6x79es2kge1fgfyj3uGbiJF3ztQUSzcFYVZUZUFfRpdrKaXlxaDPVZOrTvRbS9 iL4g== 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: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=gQMzr2V1uRmYi+UxjrCSQBKLILw5jZ6kFg3CmC13PYw=; b=pjO/jQl0udPFZn1x4dQahafMCCfo1WSLPDlndwyjx8+jlTxWp5ld9Dy84DqGVOrWMh HuyIuIfRf5pFLGjEuSAH97AaF/ouHwfRM/DimCGF0dgQCdWhVG7fN1D4ODZes12Lp9h0 88OD624BIUiH7dE6wfs8VmQ7hwTwyxWXHFlHYnQRPjPdNl0MR+C1yxHsuowBKOj+vpLM dIbdF0HTZi1jBEXoDtpBtdzkJqBtAccfv0wKDn9oVyVVVSJ7XNadwVJH3gDta009qCjs oaQemtiNjJGxxUDaJ287NoC+auCzwhE9ht4tAEeEbMGFUKpUbBFb/vtIuqSqJmNf9SGQ 4/yg== 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=gQMzr2V1uRmYi+UxjrCSQBKLILw5jZ6kFg3CmC13PYw=; b=CmMy0iHiy6uu0pYgQaTdqce04zNHsKKOyPo8vUoRiNoUJU9m/Qjuokwq7klezjq8ol e9QsEhXo0gMR95zzMp4SXqwZUakohYN6QnW0OjXRN07HZsGoH5O5/ZCEkLpwfjhTNOAs NbiDpwOg9DTARRARMZA3FqAPUqLVNrcQn44LNN06ess8eV0V/WtxXXoAYScygqCyXFTi Pj/E6hygbKCIxOOsJH1quuIq4f1lPpazK0yfxcJcsqfEg03FTlpiMrzofV21h1yMZcFo sqKTpwjegEeMfSkMj+kTLiQJY9+lKFmtvxUtmV4V/RQmkxvZQwzocOyUi+uNIq7/UXbQ zAFw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AGi0PuYHST/Hv4fJpuvK68C7QO1lkVMTY0gGVcuFHyT1T874/eUcFuLZ ji/CXWMRf2L/FM5SAKqAnlY= X-Google-Smtp-Source: APiQypJxG7BG4IL2uuRgEgVHTuzH44tYebW+yU1QHEuQqvuR0kjUHObKx9oYBJPYAlhQZ8zVKle7aw== X-Received: by 2002:a7b:c944:: with SMTP id i4mr6686819wml.144.1587064450349; Thu, 16 Apr 2020 12:14:10 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a1c:7ec2:: with SMTP id z185ls5614602wmc.1.canary-gmail; Thu, 16 Apr 2020 12:14:09 -0700 (PDT) X-Received: by 2002:a7b:c7d6:: with SMTP id z22mr6704507wmk.73.1587064449807; Thu, 16 Apr 2020 12:14:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587064449; cv=none; d=google.com; s=arc-20160816; b=lyer+6rgQAd5QaFqe086IlgwomVpABhuvNhYCn/69FgboC5AzI8FK9YGA0IGq5Qk5f O+VFPi0/iwwelDt+kwgQ+ln+VCjg3OkcEWwegxlAvj+8FmoIxL/+GVNCHyDT1wdSXBDT IBqAn9KyFO97dulw17uaGtgxTWhKK0NHSQKat3iOEJIUCcdR/fVhr/7WBaAWh4xxqY8v MK4mIryXVIfM2jSod9WsHPidMjsWkzmUn4fKiyuqMZtaU+KkshrkIxbOIBMVDnQwG6p2 2yXjaiwO3bOqb7DVX+FbAd6HTXE8lK/ujaCyL5mEX9k8EfjcPDpNQWnMoErHhH0rnhxR /DWg== 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=Tkt5DBfZ2xzrCBf4QjCDwWRfwzxsReu37ykiHo2vryQ=; b=Rc2QxXSkIqtmDgIo/+PqEFCuJqKgPnytOwyQvWPDqNiVaiuojsobfX5mchVymbEH5d bOM1OzPSrIRxilcYG4/7W26NpezdhjYoJO6gfSWQRb8iiJWO5p2fSIGvSUCspHRqZCzw pHso3MDGWZBMK0BFEZc5KHpuGUwbb6VIsMpnEs9yM+Lo8+o8bZjIR2lvu0iMzzjCTnak dbAvP1A3ZIdqs3AZ2BJfDsezRiuaRYRxzhpF8ukcccL5WyBgV0isnR5xDHYsoxw/c93s g+pKw9ZrU5QCH6uFq6F16KBWu3iVxz4zYTM7717w6QqCuVt+Ar3k02MO0Wfkp8eJWXfE Qqiw== 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 f129si171459wmf.2.2020.04.16.12.14.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Apr 2020 12:14:09 -0700 (PDT) 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 4938694cRTz1rrkY; Thu, 16 Apr 2020 21:14:09 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4938694NfPz1qqkp; Thu, 16 Apr 2020 21:14:09 +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 cA7NwYRMJOMb; Thu, 16 Apr 2020 21:14:08 +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; Thu, 16 Apr 2020 21:14:08 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 9A00145405A4; Thu, 16 Apr 2020 21:14:08 +0200 (CEST) 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 2-nTHx7FSVyc; Thu, 16 Apr 2020 21:14:06 +0200 (CEST) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.38]) by babic.homelinux.org (Postfix) with ESMTP id 38FF74540832; Thu, 16 Apr 2020 21:14:03 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH] Fix coverity #292128 Date: Thu, 16 Apr 2020 21:14:01 +0200 Message-Id: <20200416191401.10717-4-sbabic@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200416191401.10717-1-sbabic@denx.de> References: <20200416191401.10717-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: 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: , Signed-off-by: Stefano Babic --- core/swupdate.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/core/swupdate.c b/core/swupdate.c index 48d9f49..c749782 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -447,9 +447,16 @@ static int _remove_directory_cb(const char *fpath, const struct stat *sb, static int remove_directory(const char* path) { - char* dpath = alloca(strlen(get_tmpdir())+strlen(path)+1); - sprintf(dpath, "%s%s", get_tmpdir(), path); - return nftw(dpath, _remove_directory_cb, 64, FTW_DEPTH | FTW_PHYS); + char* dpath; + int ret; + if (asprintf(&dpath, "%s%s", get_tmpdir(), path) == + ENOMEM_ASPRINTF) { + ERROR("OOM: Directory %s not removed", path); + return -ENOMEM; + } + ret = nftw(dpath, _remove_directory_cb, 64, FTW_DEPTH | FTW_PHYS); + free(dpath); + return ret; } #endif