From: Andi Kleen Subject: Re: [RFC PATCH 33/35] Add the Xenbus sysfs and virtual device hotplug driver. Date: Tue, 9 May 2006 18:28:31 +0200 Message-ID: <200605091828.31686.ak@suse.de> References: <20060509084945.373541000@sous-sol.org> <20060509085200.826853000@sous-sol.org> <20060509160635.GB7237@mipter.zuzino.mipt.ru> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20060509160635.GB7237@mipter.zuzino.mipt.ru> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: virtualization@lists.osdl.org Cc: Chris Wright , Ian Pratt , xen-devel@lists.xensource.com, Alexey Dobriyan , linux-kernel@vger.kernel.org List-Id: xen-devel@lists.xenproject.org On Tuesday 09 May 2006 18:06, Alexey Dobriyan wrote: > > +/* Simplified asprintf. */ > > +char *kasprintf(const char *fmt, ...) > > +{ > > + va_list ap; > > + unsigned int len; > > + char *p, dummy[1]; > > + > > + va_start(ap, fmt); > > + /* FIXME: vsnprintf has a bug, NULL should work */ > > + len = vsnprintf(dummy, 0, fmt, ap); > > + va_end(ap); > > + > > + p = kmalloc(len + 1, GFP_KERNEL); > > + if (!p) > > + return NULL; > > + va_start(ap, fmt); > > + vsprintf(p, fmt, ap); > > + va_end(ap); > > + return p; > > +} > > This should go to lib/ First for kernel usage I think it should have a maximum length parameter to avoid dumb code from being easily exploited. And the bug should be fixed in vsnprintf instead of being worked around. -Andi