From patchwork Thu Jun 15 18:24:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Greer X-Patchwork-Id: 9789819 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 6E56760325 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 674212862E for ; Thu, 15 Jun 2017 18:26:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C2B028647; 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 E010E2861E for ; Thu, 15 Jun 2017 18:26:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752753AbdFOS01 (ORCPT ); Thu, 15 Jun 2017 14:26:27 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:50451 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753176AbdFOSZa (ORCPT ); Thu, 15 Jun 2017 14:25:30 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 254B820A7C; Thu, 15 Jun 2017 14:25:19 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute3.internal (MEProxy); Thu, 15 Jun 2017 14:25:19 -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=1hV aaDzL1h7fv3uUyqFxpe/q1aiiVty81luM2K2tWU4=; b=cvVG4LapJ3CP6PJsohq b4kyIYFjTChhZ1ci6vzPY5ikDAqYkrFX3UYDglY0bLmGLAC7wWybzFfLcT2WvKnh B2z22k8tYT50r9Q5iOf37+/cAlpKMHAXvLiJCbJEQZwqLJWIVVGH7ss1cmnkXDDY qwQnWjQIM8ULqM96CYIj5Q/k= 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=1hVaaDzL1h7fv3uUyqFxpe/q1aiiVty81luM2K2tW U4=; b=nuDs/U46oC4YRiBhHm0xr4rFbgjqg7OnF/UI7DwYbbQ31g9Y02IqM8i/K p4JXjf1VOvhTipRJJLEn2MW/YPEGodNplcQKgdN55+s1w2mBtvAbfBdRbcN7ZBQw neNylqOYlN7P1eeD4e2xtAqbkbZP43NQDbZ93/Gk9K0viQpyw1AcfJ0EmQPXWdVn MSKwMkwOlVAfHRgxZmPvcBOrLpAxfOROsGFxNn/QZeSzbtXKXIkNrna3xHCB4Qn/ 8tzbQv3oT0f+SDN7XYOsyFPnItHxQZ06CjaDgfRF3s4ePebocKfthmwOAUPoeSCd gFoAVgLQsNikbbHLDNRRDjn6G6zFg== X-ME-Sender: X-Sasl-enc: cu4FKoYNsRx0HoWmzYeOfZb1iq2kolhSpAZ35Boh6pK9 1497551118 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 D89EC7E96F; Thu, 15 Jun 2017 14:25:18 -0400 (EDT) Received: from blue.animalcreek.com (localhost [127.0.0.1]) by blue.animalcreek.com (Postfix) with ESMTP id 97EF5A20536; Thu, 15 Jun 2017 11:25:17 -0700 (MST) From: Mark Greer To: Samuel Ortiz Cc: linux-wireless@vger.kernel.org, linux-nfc@lists.01.org, Mark Greer Subject: [PATCH 05/23] ndef: Discard records containing errors Date: Thu, 15 Jun 2017 11:24:58 -0700 Message-Id: <20170615182516.4508-6-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 Currently, near_ndef_parse_msg() adds records even when they contain erroneous record types. This can later cause neard to exit when it tries to signal dbus with incomplete record information. Avoid this by ignoring records that contain bad record types (and all of the records that follow in the same NDEF message). Signed-off-by: Mark Greer --- src/ndef.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ndef.c b/src/ndef.c index 7a3c76b..38dcf72 100644 --- a/src/ndef.c +++ b/src/ndef.c @@ -2845,7 +2845,6 @@ GList *near_ndef_parse_msg(uint8_t *ndef_data, size_t ndef_length, case RECORD_TYPE_WKT_COLLISION_RESOLUTION: case RECORD_TYPE_WKT_ERROR: case RECORD_TYPE_UNKNOWN: - case RECORD_TYPE_ERROR: break; case RECORD_TYPE_WKT_HANDOVER_REQUEST: @@ -2927,6 +2926,8 @@ GList *near_ndef_parse_msg(uint8_t *ndef_data, size_t ndef_length, goto fail; break; + case RECORD_TYPE_ERROR: + goto fail; } record->data_len = record->header->header_len +