From patchwork Thu Jun 15 18:24:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Greer X-Patchwork-Id: 9789785 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 9C97760325 for ; Thu, 15 Jun 2017 18:25:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 954022848F for ; Thu, 15 Jun 2017 18:25:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8957A2861D; Thu, 15 Jun 2017 18:25:23 +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 1BF142848F for ; Thu, 15 Jun 2017 18:25:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753098AbdFOSZU (ORCPT ); Thu, 15 Jun 2017 14:25:20 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:50455 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751888AbdFOSZT (ORCPT ); Thu, 15 Jun 2017 14:25:19 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id AC4A0207EF; Thu, 15 Jun 2017 14:25:18 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute3.internal (MEProxy); Thu, 15 Jun 2017 14:25:18 -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=lrO MAKTcySgIUMK+ilDpHXVuWmDT9VbDcrlFMM/byF0=; b=AyK81lRmRnku9e2r3lu nKDCm3bbIn0EtTlZ1XrY+Xlk72UOyII0oyyOqi1EZsC67vXkiGAMly49vE4JIPrW +1zSRZYSZ3iYh/KKOA0ZRN84iuTNP0Iwp2Ge3y9fy0GG+PaoFNTN6VgtPnA5+HFH ObN9UG4+aIBsll0iwjcz1lXY= 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=lrOMAKTcySgIUMK+ilDpHXVuWmDT9VbDcrlFMM/by F0=; b=q49Y6RtSGZSgy9c5usW+dyWd/YPdsUpQw9tUVO6GO6IEohR3Q8pWc6Ctf F83ra/fV9+GK8piVAPygJe0hpNHF0xbsmS9S3N8wVP6fghrKPOrYjhwNiKfWt8eJ UdPXeWV2QpPtItukigwY7RtPNasPHByc9pyDo/r67rQc8R1qklub5Alwti60T+Py l8ztuRddLhDXi4kM1Foa8ZIBTpZa3GSMR36T8y5a+OFWf5XnfiDuVxEW5GKYQu8r szkgrtpRF+STtMIfef4lImjlylFew5Oc87xKZQksIRFXqqPapBbcP6J3FlmY4Go1 4ZHSJHgrDxxVjmfvZJisA/TmAStFA== X-ME-Sender: X-Sasl-enc: cu4bOIIUrgVoB4CmzYeOfZb1iq2kolhSpAZ35Boh6pK9 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 44F2D24953; 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 8C5A0A20529; 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 04/23] ndef: Verify RTD record type name encodings Date: Thu, 15 Jun 2017 11:24:57 -0700 Message-Id: <20170615182516.4508-5-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 The NFC Forum's Record Type Definition (RTD) Technical Specification version 1.0, section 3.4 (RTD Type Names Requirements) specifies that RTD type name encodings MUST be done according to the ASCII chart in Appendix A (Character Set for Record Types). Enforce this by checking that all of the RTD type name encodings are valid before determining their type. Conveniently, isprint() does the correct checking. Signed-off-by: Mark Greer --- src/ndef.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ndef.c b/src/ndef.c index 03d6b13..7a3c76b 100644 --- a/src/ndef.c +++ b/src/ndef.c @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -881,6 +882,8 @@ static enum record_type get_external_record_type(uint8_t *type, static enum record_type get_record_type(enum record_tnf tnf, uint8_t *type, size_t type_length) { + unsigned int i; + DBG(""); switch (tnf) { @@ -891,6 +894,10 @@ static enum record_type get_record_type(enum record_tnf tnf, break; case RECORD_TNF_WELLKNOWN: + for (i = 0; i < type_length; i++) + if (!isprint(type[i])) + return RECORD_TYPE_ERROR; + if (type_length == 1) { if (type[0] == 'T') return RECORD_TYPE_WKT_TEXT;