From patchwork Thu Jun 15 18:25:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Greer X-Patchwork-Id: 9789823 X-Patchwork-Delegate: sameo@linux.intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C57AB6038F for ; Thu, 15 Jun 2017 18:26:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEA8E2861E for ; Thu, 15 Jun 2017 18:26:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3D7F2862E; Thu, 15 Jun 2017 18:26:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5ED3F2861E for ; Thu, 15 Jun 2017 18:26:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752886AbdFOS0c (ORCPT ); Thu, 15 Jun 2017 14:26:32 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:33989 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750749AbdFOSZ2 (ORCPT ); Thu, 15 Jun 2017 14:25:28 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 31A2120AC0; Thu, 15 Jun 2017 14:25:20 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute3.internal (MEProxy); Thu, 15 Jun 2017 14:25:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=animalcreek.com; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=Cun rt38w6C2z9auaAktpMvGVN+ixLl9asm4FdMuxCxQ=; b=iW7t6MMqhZv5M3+U8Qo hImQ+DCnqRDNVhtIsdzLb8LkSZQm5yRvEBWdVqwufJxDlqxZk1S1Dv/wOUQLRPew ZsNgPuY/s8xBPaB+KgjLUgS48d8zG+/8m5+KuFG2pah/DnQbMI3AcRLka75hmH+k 2j+y02MmJJ2yUXkB8+CrQM8M= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=Cunrt38w6C2z9auaAktpMvGVN+ixLl9asm4FdMuxC xQ=; b=C/rJ/IRgxw46a4srOiSXnAAXYpCP84mOgwQctTL7WNoRxbd/8H7ItBhZ/ a2ENtLbOh3EtEI0DpAMtwRqG88lruaiOvqguCxBTaMeQTgF6Zj7MOe0MCQzctMZN lxNt6mATBIH0TIVv9NJRG+3r8wH98ohwypzfMqQoSlGox9GxKAlfBRmCUZh6RNe+ sB0uftn+Nc7kSd4bv7YQ5sNh95JC0y/AEPVJDcp+wg0U+mU+eDTnhCJDqX/nGCJ6 g6ND1c0Pe0vPjkgMmXWcT9VDivSLyiFmFnlZmsqtS2wL0T0SfQHzM6gg9VnlC6yh SNgjcG216i4o7982M3h4cCo/1MR1Q== X-ME-Sender: X-Sasl-enc: GJkT0kLpax8Ajdw01kMCVXTrjBHToFb0Ue7zboi8IvZT 1497551119 Received: from blue.animalcreek.com (ip68-2-81-12.ph.ph.cox.net [68.2.81.12]) by mail.messagingengine.com (Postfix) with ESMTPA id D13F47E85D; Thu, 15 Jun 2017 14:25:19 -0400 (EDT) Received: from blue.animalcreek.com (localhost [127.0.0.1]) by blue.animalcreek.com (Postfix) with ESMTP id 4DFB7A20280; Thu, 15 Jun 2017 11:25:18 -0700 (MST) From: Mark Greer To: Samuel Ortiz Cc: linux-wireless@vger.kernel.org, linux-nfc@lists.01.org, Mark Greer Subject: [PATCH 20/23] nfctype5: Discard extra byte in RMB response data Date: Thu, 15 Jun 2017 11:25:13 -0700 Message-Id: <20170615182516.4508-21-mgreer@animalcreek.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170615182516.4508-1-mgreer@animalcreek.com> References: <20170615182516.4508-1-mgreer@animalcreek.com> Organization: Animal Creek Technologies, Inc. Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sometimes there can be an extra byte in the response data for Read Multiple Blocks (RMB) commands so discard it whenever that happens. Signed-off-by: Mark Greer --- plugins/nfctype5.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/nfctype5.c b/plugins/nfctype5.c index a91d8f5..d6eec3c 100644 --- a/plugins/nfctype5.c +++ b/plugins/nfctype5.c @@ -654,7 +654,7 @@ static int t5_read_multiple_blocks_resp(uint8_t *resp, int length, void *data) uint8_t blk_size = near_tag_get_blk_size(tag); size_t data_length; GList *records; - int err; + int err, expected_len; DBG(""); @@ -665,9 +665,16 @@ static int t5_read_multiple_blocks_resp(uint8_t *resp, int length, void *data) goto out_done; length -= NFC_HEADER_SIZE; + expected_len = sizeof(*t5_resp) + + cookie->nb_requested_blocks * blk_size; - if (length != (int)(sizeof(*t5_resp) + - (cookie->nb_requested_blocks * blk_size))) { + /* + * Sometimes an extra byte is returned in RMB response data. + * Discard the extra byte whenever that happens. + */ + if (length == (expected_len + 1)) { + length--; + } else if (length != expected_len) { err = -EIO; goto out_done; }