From patchwork Tue Nov 17 15:24:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Clayton X-Patchwork-Id: 7638051 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 4358E9F2EC for ; Tue, 17 Nov 2015 15:26:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6DBEA200E7 for ; Tue, 17 Nov 2015 15:25:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 89AC020376 for ; Tue, 17 Nov 2015 15:25:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753986AbbKQPZ3 (ORCPT ); Tue, 17 Nov 2015 10:25:29 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:33644 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753969AbbKQPZZ (ORCPT ); Tue, 17 Nov 2015 10:25:25 -0500 Received: by pabfh17 with SMTP id fh17so12405359pab.0; Tue, 17 Nov 2015 07:25:25 -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=ZR7ROXgvcRn/h/T7VJ9T1erhNKjKhuyZsjpM/zHUpAQ=; b=KYFdxUftmlOO+siD/8RHqUhPRXIGaBQ4/CQj64T+ydE/+p09Vp2uKHfoVNjMFidEum JOaCFX0nYuUNLgFP4tlpIsbl1RQieIvtmrM8B25TrGBcZg02tXjqeeNyK8Is2byOS6Q8 csnpozhhtQBFyXP0Zf0f6tbz3hIXKr/3crcueKNIz65cKgtT4BX3oIyVmy4tvD56t2v0 1C+aNzjb4sQ+HmlSQ8J6beIzhHF8CQfgOyTzBLi8DaqLoHu8N+MCYyon35dNci4bRi1d cEUpPlSpP2gF4qveHuCioLe8VctxwV3vDBEfca7+w+OzR5LHb6UewmEP8FHaWlTVYDPL t1qA== X-Received: by 10.68.182.197 with SMTP id eg5mr35097840pbc.114.1447773925427; Tue, 17 Nov 2015 07:25:25 -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 d7sm43701843pas.31.2015.11.17.07.25.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Nov 2015 07:25:24 -0800 (PST) From: Joshua Clayton To: Mark Brown Cc: Jonathan Corbet , Adrian Remonda , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, Joshua Clayton Subject: [PATCH 5/8] Documentation/spi/spidev_test.c: check error Date: Tue, 17 Nov 2015 07:24:25 -0800 Message-Id: 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.4 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 --- Documentation/spi/spidev_test.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Documentation/spi/spidev_test.c b/Documentation/spi/spidev_test.c index 273f667..2ff5fe8 100644 --- a/Documentation/spi/spidev_test.c +++ b/Documentation/spi/spidev_test.c @@ -85,13 +85,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 {