From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753623AbbFDMWI (ORCPT ); Thu, 4 Jun 2015 08:22:08 -0400 Received: from mail-pd0-f173.google.com ([209.85.192.173]:34963 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752791AbbFDMWF (ORCPT ); Thu, 4 Jun 2015 08:22:05 -0400 Date: Thu, 4 Jun 2015 17:51:53 +0530 From: Sudip Mukherjee To: Joe Perches Cc: Thomas Petazzoni , Noralf =?iso-8859-1?Q?Tr=F8nnes?= , Greg Kroah-Hartman , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: fbtft: fix out of bound access Message-ID: <20150604122153.GA18177@sudip-PC> References: <1433418121-9434-1-git-send-email-sudipm.mukherjee@gmail.com> <1433419943.4861.167.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433419943.4861.167.camel@perches.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 04, 2015 at 05:12:23AM -0700, Joe Perches wrote: > On Thu, 2015-06-04 at 17:12 +0530, Sudip Mukherjee wrote: > > size of str is 16, but in snprintf the size was mentioned as 128. > [] > > diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c > [] > > @@ -1096,7 +1096,7 @@ static int fbtft_init_display_dt(struct fbtft_par *par) > > /* make debug message */ > > msg[0] = '\0'; > > for (j = 0; j < i; j++) { > > - snprintf(str, 128, " %02X", buf[j]); > > + snprintf(str, 16, " %02X", buf[j]); > > using sizeof(str) is probably more robust > > msg isn't big enough to hold the maximum possible output. yes, it will not hold. i didn't notice msg size. > > If this is really useful, and I rather doubt it is, > it'd probably be better to use a loop to output > multiple lines, one for each register. I will send in a v2 doing this. regards sudip > >