From owner-svn-src-all@FreeBSD.ORG Thu Nov 12 00:52:14 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B1E5A106568F; Thu, 12 Nov 2009 00:52:14 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A0FE48FC1D; Thu, 12 Nov 2009 00:52:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nAC0qEE1012883; Thu, 12 Nov 2009 00:52:14 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nAC0qEjC012881; Thu, 12 Nov 2009 00:52:14 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <200911120052.nAC0qEjC012881@svn.freebsd.org> From: Attilio Rao Date: Thu, 12 Nov 2009 00:52:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r199209 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Nov 2009 00:52:14 -0000 Author: attilio Date: Thu Nov 12 00:52:14 2009 New Revision: 199209 URL: http://svn.freebsd.org/changeset/base/199209 Log: The building the dev nameunit string, in devclass_add_device() is based on the assumption that the unit linked with the device is invariant but that can change when calling devclass_alloc_unit() (because -1 is passed or, more simply, because the unit choosen is beyond the table limits). This results in a completely bogus string building. Fix this by reserving the necessary room for all the possible characters printable by a positive integer (we do not allow for negative unit number). Reported by: Sandvine Incorporated Reviewed by: emaste Sponsored by: Sandvine Incorporated MFC: 1 week Modified: head/sys/kern/subr_bus.c Modified: head/sys/kern/subr_bus.c ============================================================================== --- head/sys/kern/subr_bus.c Thu Nov 12 00:46:28 2009 (r199208) +++ head/sys/kern/subr_bus.c Thu Nov 12 00:52:14 2009 (r199209) @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1584,7 +1585,7 @@ devclass_add_device(devclass_t dc, devic PDEBUG(("%s in devclass %s", DEVICENAME(dev), DEVCLANAME(dc))); - buflen = snprintf(NULL, 0, "%s%d$", dc->name, dev->unit); + buflen = snprintf(NULL, 0, "%s%d$", dc->name, INT_MAX); if (buflen < 0) return (ENOMEM); dev->nameunit = malloc(buflen, M_BUS, M_NOWAIT|M_ZERO);