From patchwork Wed Oct 15 23:14:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zach Brown X-Patchwork-Id: 5087441 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7C8C6C11AC for ; Wed, 15 Oct 2014 23:14:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BD03C20136 for ; Wed, 15 Oct 2014 23:14:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BCE182012E for ; Wed, 15 Oct 2014 23:14:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751298AbaJOXOs (ORCPT ); Wed, 15 Oct 2014 19:14:48 -0400 Received: from mail-wg0-f51.google.com ([74.125.82.51]:58861 "EHLO mail-wg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750887AbaJOXOr (ORCPT ); Wed, 15 Oct 2014 19:14:47 -0400 Received: by mail-wg0-f51.google.com with SMTP id b13so2439475wgh.34 for ; Wed, 15 Oct 2014 16:14:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=N0GlQHIezn6LwuN6x9+jDWJEjhRnvVgCxEVK9DcF9Lk=; b=Fz4SajotqTcohIm8DvLPgMzdFCRe6yawvyR4B5HUekMNoxrTTmuXI3ow9CFKS/dZGl VMfUYvkusA1uLbyNzmKbgJqjbtJHVwebfkaG05VicTgb83zU+u4/TzcGgHzC29YWlQnj qujAx/LbqJ/z/PFTNFPst2/WzhkqgSRMoniRjeGfx6pwDQ6pGm/7ljXNxWCvX5lmhErs keMMnYns3CV1Y657m0pRckKKMf00t1gFfjqH0tyFTLmGCTctFvWd84mfjXz7Mjg7Pyw3 cjus2TojHQYDM86nA5OWXv41mnvWaYBBcM70LbvfvaAmaR/2EJSD9OwQq/uKAD3c94NX HiLg== X-Gm-Message-State: ALoCoQnHSTB/2W4gpFIa7A532w1bupLc/9X5b/J4LkYywEBJM+7OfMbeNUEqP3jPSeqSQyfUSWWy X-Received: by 10.194.242.4 with SMTP id wm4mr15310119wjc.61.1413414886455; Wed, 15 Oct 2014 16:14:46 -0700 (PDT) Received: from lenny.home.zabbo.net (tetsuo.zabbo.net. [50.193.208.193]) by mx.google.com with ESMTPSA id o1sm25390716wja.25.2014.10.15.16.14.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Oct 2014 16:14:45 -0700 (PDT) From: Zach Brown To: linux-btrfs@vger.kernel.org, David Sterba Subject: [PATCH 1/4] btrfs-progs: check sscanf return code Date: Wed, 15 Oct 2014 16:14:18 -0700 Message-Id: <1413414861-28097-2-git-send-email-zab@zabbo.net> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1413414861-28097-1-git-send-email-zab@zabbo.net> References: <1413414861-28097-1-git-send-email-zab@zabbo.net> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY, URIBL_WS_SURBL autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP coverity warned that the return code from sscanf() assigned to 'i' wasn't checked before being assigned again. Check it. Signed-off-by: Zach Brown --- utils.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/utils.c b/utils.c index c2f30d4..51e55be 100644 --- a/utils.c +++ b/utils.c @@ -1574,7 +1574,11 @@ scan_again: strcpy(fullpath,"/dev/"); while(fgets(buf, 1023, proc_partitions)) { - i = sscanf(buf," %*d %*d %*d %99s", fullpath+5); + ret = sscanf(buf," %*d %*d %*d %99s", fullpath+5); + if (ret != 1) { + fprintf(stderr, "failed to scan device name from /proc/partitions\n"); + break; + } /* * multipath and MD devices may register as a btrfs filesystem