From patchwork Wed Nov 18 22:30:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Clayton X-Patchwork-Id: 7653121 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C14C79F1D3 for ; Wed, 18 Nov 2015 22:33:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0EA5B204E0 for ; Wed, 18 Nov 2015 22:33:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4029A204A2 for ; Wed, 18 Nov 2015 22:33:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757088AbbKRWch (ORCPT ); Wed, 18 Nov 2015 17:32:37 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:36771 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933607AbbKRWcD (ORCPT ); Wed, 18 Nov 2015 17:32:03 -0500 Received: by pacdm15 with SMTP id dm15so58191740pac.3; Wed, 18 Nov 2015 14:32:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=3RshwY/16g9Mvce5qF4ihlIx2hihQPHS/lq21ocKeCs=; b=CJ5m/ye94teFAL7ZusmhAjfklyExfDkTF+M2tGEEAvXonLPsr8kDsej3Y0VmxaMCUP 8559nIv0yYE0dWsc45UkYkNK1CLZ0jwfz+0X5dbeejwp5gJO439ZpSVF/wBuJ3ZewWEG E5Tzh8hi7jqO1xFTxzXI4sUOrIIVQdWNwioL8XUKyGlfU/g1QPjOajmXl7f9w9QwB+XY tUCXmHNaGNGe674ysbKZJJxxGD6klVo7NhKTbe8IYnXHEwm+5TPTeRikUgaJEg61iUjJ X0ayJWm1xFWbHgLZ5QbvyY8vMku7i2erVckBfgC2VULFpaH081c5ANlD4ny4YMAPxQIW KZLw== X-Received: by 10.68.198.67 with SMTP id ja3mr5624623pbc.73.1447885922609; Wed, 18 Nov 2015 14:32:02 -0800 (PST) Received: from localhost.localdomain (68-185-59-186.static.knwc.wa.charter.com. [68.185.59.186]) by smtp.gmail.com with ESMTPSA id we9sm5836249pab.3.2015.11.18.14.32.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Nov 2015 14:32:01 -0800 (PST) From: Joshua Clayton To: Mark Brown , linux-spi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Anton Bondarenko , Joshua Clayton Subject: [PATCH v2 5/6] spi: spidev_test: check error Date: Wed, 18 Nov 2015 14:30:41 -0800 Message-Id: <2bbb0374d7fd390a04ceb8d7b552f1a8d946c0f0.1447880230.git.stillcompiling@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY 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 Check the result of sscanf to verify a result was found. report and error and abort if pattern was not found. Signed-off-by: Joshua Clayton --- tools/spi/spidev_test.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/spi/spidev_test.c b/tools/spi/spidev_test.c index 02fc3a4..322370d 100644 --- a/tools/spi/spidev_test.c +++ b/tools/spi/spidev_test.c @@ -86,13 +86,17 @@ static void hex_dump(const void *src, size_t length, size_t line_size, char *pre static int unescape(char *_dst, char *_src, size_t len) { int ret = 0; + int match; char *src = _src; char *dst = _dst; unsigned int ch; while (*src) { if (*src == '\\' && *(src+1) == 'x') { - sscanf(src + 2, "%2x", &ch); + match = sscanf(src + 2, "%2x", &ch); + if (!match) + pabort("malformed input string"); + src += 4; *dst++ = (unsigned char)ch; } else {