Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp96836pxk; Fri, 11 Sep 2020 01:10:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymfqDrOcpxbB1F5nNGggeOMJEKdxt6N8RUIEwrm0eM9VLCVYPFuBsZpYm1p+wD8gQWmQmH X-Received: by 2002:a17:906:5e59:: with SMTP id b25mr941000eju.414.1599811804330; Fri, 11 Sep 2020 01:10:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599811804; cv=none; d=google.com; s=arc-20160816; b=MNQNFSf/X3pepf0teYfwmRroi0dlyEf8K7IYbGHnq25Lsghr/NCCun2ZAhWwwdp/qM gDrwq4Oo7uGiPFdZ/mi2hcTo7V0Ax1LM6/Hny9Hw3M24zMF2oCD1hPrLQYzTi+ngyb0m ypyazNqhFrlO9w8KD57POsDdWYQlOtLRBCEmT+5F17GsURhvD/XGsh3Y88S7pa4X2q/L JIz8u3C7EeOGq0C+kKY39xgk1UW2cgYhtsSXWNQ4ftYxXItJtv1PgqfKhkQBr4QRBcRU oLbgLil22U90Vu9z05RqhSn6411xJ/ABLNrrErgM1ebYaOf71ZQcLGCX+bdVoyn+fjVI 469w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:cc:dkim-signature; bh=s3NbMTOumyl+6eyS9PrceN8AWSkDKTQT8h3qOtC2ULA=; b=Qo/J4W5sCcPkrY5PVK0wbSKNfPOLYVWQ56HfFDGSyidRrKWXzCSSZua4BGB4pdPEIv 5tylUxtwc/PrL9w8J+It1uwp/7AF7wOqWiuoBL46TKBiW0Fxh399plJEkulpsh2/mZW6 pUi/Gf5TJqP2AAtTAhJd1vqv0nMQMzLCd/UYW0zcrNtD3krfc0kRn/ROp5xsOQ4BlyxO ktc0gRNHy7YwbNIhxs2IZj+1CV3I15ErhyCPy7uHK90WwfUN0R3ejS+JM1+T666EtQtk wr21sKOMybujReRFHXET/ycxf9uCcVB3R5cLa+CfihoaFlAwXlI4bnWksJt679P9O/VS NoBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=spcFpZsO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fx6si682267ejb.432.2020.09.11.01.09.41; Fri, 11 Sep 2020 01:10:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=spcFpZsO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725837AbgIKIIk (ORCPT + 99 others); Fri, 11 Sep 2020 04:08:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725838AbgIKIIc (ORCPT ); Fri, 11 Sep 2020 04:08:32 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B702C061756; Fri, 11 Sep 2020 01:08:30 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id c18so10520070wrm.9; Fri, 11 Sep 2020 01:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=cc:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=s3NbMTOumyl+6eyS9PrceN8AWSkDKTQT8h3qOtC2ULA=; b=spcFpZsOnUNLRquvJMeGL3k4PbtXGBU/MgQ+wZBuJ2iKe3DJFrCreFxJKFHMHb3RZ6 mPiFTg2b0En5DqJGkjwtJAQ0nO8ruIhuSpg2c5P6gXGTHpmKa/h4hDUTQTs9q8zJws8t yfGmqBemxQj7JZBf2hX0YrZOrFAlEOiVp62eGzbGmcQVP4jjILreezr++D6Ef8wUJDyj 81yeS/wDJnAfJQN/81/yIaUrbezdFrIjhId9ck8uE0iJykZBPKaaeK0dLxORAPgseJaV 3HboL17CCCodxXiPRifjhiYA8LdJ/X0T2gWdx27Y+PCpoaXwiAwfKI8VBnzPXdskrmRn bwmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:cc:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=s3NbMTOumyl+6eyS9PrceN8AWSkDKTQT8h3qOtC2ULA=; b=EgqJgY1oQqsUANKqd7p9Z/NAmAEobqXfB1ZjySNEkHf73Cq/k9BsjMwVhzKiGFzT18 Brs0DPr29InWnfaWqFHVNI3mzN3tpCoMM7nh7BQQBMOeUs3jDuWdtotlRrN1Vz61oEtM gD1IF/8kzOGdHkPBYfyNXnYgwnXSjbcIVLaH8WouG54+EMYHlBRljk5Q9OmsLW30h+gC bNDqEgy4M5cN0V6uMP1P8/Ojw4wfb0m28Aj84T7k2iaMzo2hAaaf7symvjqTGG8i7fFK LZPsnLMMiYYZQ95dDcbthgtxnVP7vIMD/KEy9vBP7kHWqwDIMz4u+dbcL+ZEak8jzuIZ szRw== X-Gm-Message-State: AOAM532J9U3xJzBwq07+iEVwKizAA/JPwrNJX4yMdqzLShr2b3VnDTpW NcjPF8ZyftuU2TTbeQmowCF4QnnDD/w= X-Received: by 2002:adf:ec82:: with SMTP id z2mr799913wrn.214.1599811708686; Fri, 11 Sep 2020 01:08:28 -0700 (PDT) Received: from ?IPv6:2001:a61:2479:6801:d8fe:4132:9f23:7e8f? ([2001:a61:2479:6801:d8fe:4132:9f23:7e8f]) by smtp.gmail.com with ESMTPSA id m10sm2743618wmi.9.2020.09.11.01.08.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Sep 2020 01:08:28 -0700 (PDT) Cc: mtk.manpages@gmail.com, linux-man@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 18/24] core.5: Use adequate type To: Alejandro Colomar References: <20200910211344.3562-1-colomar.6.4.3@gmail.com> <20200910211344.3562-19-colomar.6.4.3@gmail.com> From: "Michael Kerrisk (man-pages)" Message-ID: <7147904f-f135-5abd-c8b5-ff2cc4f0de0a@gmail.com> Date: Fri, 11 Sep 2020 10:08:27 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200910211344.3562-19-colomar.6.4.3@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/10/20 11:13 PM, Alejandro Colomar wrote: > 'nread' is of type 'ssize_t' > 'tot' adds up different values contained in 'nread', > so it should also be 'ssize_t', and not 'int' (which possibly overflows). > > Signed-off-by: Alejandro Colomar Thanks, Alex. Patch Applied. Cheers, Michael > --- > man5/core.5 | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/man5/core.5 b/man5/core.5 > index a87ebbaf4..45c9de845 100644 > --- a/man5/core.5 > +++ b/man5/core.5 > @@ -654,8 +654,7 @@ Total bytes in core dump: 282624 > int > main(int argc, char *argv[]) > { > - int tot; > - ssize_t nread; > + ssize_t nread, tot; > char buf[BUF_SIZE]; > FILE *fp; > char cwd[PATH_MAX]; > @@ -684,7 +683,7 @@ main(int argc, char *argv[]) > tot = 0; > while ((nread = read(STDIN_FILENO, buf, BUF_SIZE)) > 0) > tot += nread; > - fprintf(fp, "Total bytes in core dump: %d\en", tot); > + fprintf(fp, "Total bytes in core dump: %zd\en", tot); > > fclose(fp); > exit(EXIT_SUCCESS); > -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/