Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Sep 2009 07:42:59 +0000 (UTC)
From:      Andrew Thompson <thompsa@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r197561 - head/sys/dev/usb
Message-ID:  <200909280742.n8S7gxKV047061@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: thompsa
Date: Mon Sep 28 07:42:59 2009
New Revision: 197561
URL: http://svn.freebsd.org/changeset/base/197561

Log:
  Correct buffer sizes used so that they match. The old code could give the
  impression that a overflow situation existed but was not possible.
  
  Reported by:	kib
  Submitted by:	Hans Petter Selasky

Modified:
  head/sys/dev/usb/usb_device.c

Modified: head/sys/dev/usb/usb_device.c
==============================================================================
--- head/sys/dev/usb/usb_device.c	Mon Sep 28 07:42:52 2009	(r197560)
+++ head/sys/dev/usb/usb_device.c	Mon Sep 28 07:42:59 2009	(r197561)
@@ -2355,6 +2355,7 @@ usb_notify_addq(const char *type, struct
 {
 	char *data = NULL;
 	struct malloc_type *mt;
+	const size_t buf_size = 512;
 
 	mtx_lock(&malloc_mtx);
 	mt = malloc_desc2type("bus");	/* XXX M_BUS */
@@ -2362,12 +2363,12 @@ usb_notify_addq(const char *type, struct
 	if (mt == NULL)
 		return;
 
-	data = malloc(512, mt, M_NOWAIT);
+	data = malloc(buf_size, mt, M_NOWAIT);
 	if (data == NULL)
 		return;
 
 	/* String it all together. */
-	snprintf(data, 1024,
+	snprintf(data, buf_size,
 	    "%s"
 	    "%s "
 	    "vendor=0x%04x "



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200909280742.n8S7gxKV047061>