From patchwork Fri Sep 14 11:04:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 1457151 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 7BF66DF280 for ; Fri, 14 Sep 2012 11:04:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752343Ab2INLEa (ORCPT ); Fri, 14 Sep 2012 07:04:30 -0400 Received: from rcsinet15.oracle.com ([148.87.113.117]:38882 "EHLO rcsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751759Ab2INLE3 (ORCPT ); Fri, 14 Sep 2012 07:04:29 -0400 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q8EB4Lnb020497 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 14 Sep 2012 11:04:22 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q8EB4Kvj009076 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 14 Sep 2012 11:04:20 GMT Received: from abhmt108.oracle.com (abhmt108.oracle.com [141.146.116.60]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q8EB4Jmt017090; Fri, 14 Sep 2012 06:04:20 -0500 Received: from elgon.mountain (/41.212.103.53) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 14 Sep 2012 04:04:19 -0700 Date: Fri, 14 Sep 2012 14:04:14 +0300 From: Dan Carpenter To: Bruno =?iso-8859-1?Q?Pr=E9mont?= Cc: Jiri Kosina , linux-input@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] HID: picoLCD: off by one in dump_buff_as_hex() Message-ID: <20120914110414.GA1152@elgon.mountain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: acsinet22.oracle.com [141.146.126.238] Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We're placing the NUL terminator one character beyond the end of the buffer here. Signed-off-by: Dan Carpenter --- This change obviously don't make the code worse, but I'm not positive it's the right fix. I'm not sure the lines before are doing the right thing either, if we had two chars of remaining space then wouldn't it be better to put the new line and NUL in the unused space? If you decide to do it differently, then please feel to sent a patch for that and give me a Reported-by cookie. -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/hid/hid-picolcd_debugfs.c b/drivers/hid/hid-picolcd_debugfs.c index eec85b5..ff271ff0 100644 --- a/drivers/hid/hid-picolcd_debugfs.c +++ b/drivers/hid/hid-picolcd_debugfs.c @@ -390,7 +390,7 @@ static void dump_buff_as_hex(char *dst, size_t dst_sz, const u8 *data, dst[j--] = '\0'; dst[j] = '\n'; } else - dst[j] = '\0'; + dst[dst_sz - 1] = '\0'; } void picolcd_debug_out_report(struct picolcd_data *data,