Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759166AbZDJFVk (ORCPT ); Fri, 10 Apr 2009 01:21:40 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756576AbZDJFV2 (ORCPT ); Fri, 10 Apr 2009 01:21:28 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:45861 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754030AbZDJFV1 (ORCPT ); Fri, 10 Apr 2009 01:21:27 -0400 Date: Thu, 9 Apr 2009 22:17:22 -0700 From: Andrew Morton To: Andrew Patterson Cc: "Mike Miller (OS Dev)" , Jens Axboe , LKML , LKML-SCSI , mike.miller@hp.com Subject: Re: [PATCH 1/1] cciss: resubmit export uid, model, vendor, rev to sysfs Message-Id: <20090409221722.6439ba11.akpm@linux-foundation.org> In-Reply-To: <1239340134.19984.276.camel@grinch> References: <20090407180411.GA4324@beardog.cca.cpqcorp.net> <20090409215226.8b03bc2b.akpm@linux-foundation.org> <1239340134.19984.276.camel@grinch> X-Mailer: Sylpheed 2.4.8 (GTK+ 2.12.5; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 917 Lines: 25 On Fri, 10 Apr 2009 05:08:54 +0000 Andrew Patterson wrote: > > > + char model[MODEL_LEN + 1]; > > > ... > > > + return snprintf(buf, MODEL_LEN + 2, "%s\n", drv->model); > > > > Isn't the buffer sizing wrong here? Should be MODEL_LEN+1. > > > > Don't we need space for the '\0' and the '\n'? The second arg to snprintf() tells snprintf() how large the buffer is. That buffer should be sized to allow room for the trailing \0. So if MODEL_LEN represents the maximum number of characters in a string then you want: char model[MODEL_LEN + 2]; /* Room for the \n and the \0 */ ... return snprintf(buf, sizeof(model), "%s\n", drv->model); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/