From patchwork Sun Aug 23 00:31:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 509779 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 27F921402A8 for ; Sun, 23 Aug 2015 10:34:20 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=abPHIiFY; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7709C4B6F3; Sun, 23 Aug 2015 02:34:09 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VJsUUwgW5CbA; Sun, 23 Aug 2015 02:34:09 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7A71D4B713; Sun, 23 Aug 2015 02:33:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 370BC4B695 for ; Sun, 23 Aug 2015 02:32:34 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id A0kh9Ds0X--1 for ; Sun, 23 Aug 2015 02:32:34 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-io0-f182.google.com (mail-io0-f182.google.com [209.85.223.182]) by theia.denx.de (Postfix) with ESMTPS id 343C44B691 for ; Sun, 23 Aug 2015 02:32:22 +0200 (CEST) Received: by iodt126 with SMTP id t126so116319177iod.2 for ; Sat, 22 Aug 2015 17:32:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=2VWFOTUiBK8qc8Z7rvNAiTV1fKh5VWwlxP5nLY88bEo=; b=abPHIiFYzKEZ4uMtM0bnigGS+2VpHA3tuuNxr3lEiN0fpDdoOppVTi7fZc3q2/LDgE UzXYZRVykNySOkzvUzqSeEndvz4tykyrJ4FKVCUyrDUZvB4cdwomUBuQevFmUOKa/oh/ vvamqdLJGS0JqtjJIEQw1WQqhlfPKLu/F1xjuI/qXxObmD2TTz0jWcfRGF2xafgZF6jS aUGx2AH/qTHuLnXHb2h3+CXxdP/HF/6Y7xgLBKvHfl1xlPBv+1pHegEmYukQIw0k4n/i HJCKg4t7W5fVxJ+0YRbrydxei8AlNjKI9iuYe5QL4w6gtD2cs8yAwlZuLGKhXG+KoWS0 6uGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=2VWFOTUiBK8qc8Z7rvNAiTV1fKh5VWwlxP5nLY88bEo=; b=E53yUitzFE3c4r0tlZ3+TeT0B7kZZX1ENYjoEXr81JdexjdDzPN5RlT/1Vfr/nBF7N J8S5VN6m7UMO80KHag8NH1Er9Q/kHwyy6tQMqDWD+42hOEdIAiDzWdEag+EsJaZB4BAw 7zHA+fIE6x5fqHhiTbADPOu+hw0bOjYAyzM0hPKf1F/6LAn2IL58FqxGgWzpWtNIXYNH JzeaniBGAxmjE6DNaO2nlNmm/o7n7CJtAX3eOGo+gwpfIpNrDLQ4GrYg3vkdf55ux/cM Pte8y3gzejIPjTAyldd+wHTXlrwVcxcjsl4TW/nwdQ9IT0YhGV54+i15RTacUReIygIG yNKA== X-Gm-Message-State: ALoCoQkCEGiEKEYPkHD+rdy8dm4Uv4IxuId7g/f9GLc1Vi8qjmhMZQBGeG5PaCyI2Ni4YGbwIGP6 X-Received: by 10.107.8.96 with SMTP id 93mr17157169ioi.152.1440289941042; Sat, 22 Aug 2015 17:32:21 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by smtp.gmail.com with ESMTPSA id n5sm5492462iga.0.2015.08.22.17.32.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Aug 2015 17:32:18 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 6873222193E; Sat, 22 Aug 2015 18:32:14 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Sat, 22 Aug 2015 18:31:36 -0600 Message-Id: <1440289904-31280-21-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.5.0.457.gab17608 In-Reply-To: <1440289904-31280-1-git-send-email-sjg@chromium.org> References: <1440289904-31280-1-git-send-email-sjg@chromium.org> Cc: Christophe Ricard Subject: [U-Boot] [PATCH v2 20/28] tpm: Check that parse_byte_string() has data to parse X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Rather then crashing when there is no data, print an error. Acked-by: Christophe Ricard Signed-off-by: Simon Glass --- Changes in v2: None common/cmd_tpm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/cmd_tpm.c b/common/cmd_tpm.c index 65e7371..e9c6618 100644 --- a/common/cmd_tpm.c +++ b/common/cmd_tpm.c @@ -58,6 +58,8 @@ static void *parse_byte_string(char *bytes, uint8_t *data, size_t *count_ptr) size_t count, length; int i; + if (!bytes) + return NULL; length = strlen(bytes); count = length / 2;