From owner-svn-src-all@FreeBSD.ORG Mon Apr 20 20:07:40 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 139FEB54; Mon, 20 Apr 2015 20:07:40 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 02284B22; Mon, 20 Apr 2015 20:07:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3KK7dga000380; Mon, 20 Apr 2015 20:07:39 GMT (envelope-from vangyzen@FreeBSD.org) Received: (from vangyzen@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3KK7dtj000379; Mon, 20 Apr 2015 20:07:39 GMT (envelope-from vangyzen@FreeBSD.org) Message-Id: <201504202007.t3KK7dtj000379@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: vangyzen set sender to vangyzen@FreeBSD.org using -f From: Eric van Gyzen Date: Mon, 20 Apr 2015 20:07:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r281787 - head/sbin/dmesg X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 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: Mon, 20 Apr 2015 20:07:40 -0000 Author: vangyzen Date: Mon Apr 20 20:07:39 2015 New Revision: 281787 URL: https://svnweb.freebsd.org/changeset/base/281787 Log: dmesg: accommodate message buffer growth between the sysctl calls Allocate 12.5% extra space to avoid ENOMEM when the message buffer is growing steadily. Reported by: Steve Wahl (and tested) Approved by: kib (mentor) Obtained from: Dell Inc. MFC after: 1 week Modified: head/sbin/dmesg/dmesg.c Modified: head/sbin/dmesg/dmesg.c ============================================================================== --- head/sbin/dmesg/dmesg.c Mon Apr 20 20:06:25 2015 (r281786) +++ head/sbin/dmesg/dmesg.c Mon Apr 20 20:07:39 2015 (r281787) @@ -118,6 +118,9 @@ main(int argc, char *argv[]) */ if (sysctlbyname("kern.msgbuf", NULL, &buflen, NULL, 0) == -1) err(1, "sysctl kern.msgbuf"); + /* Allocate extra room for growth between the sysctl calls. */ + buflen += buflen/8; + /* Allocate more than sysctl sees, for room to append \n\0. */ if ((bp = malloc(buflen + 2)) == NULL) errx(1, "malloc failed"); if (sysctlbyname("kern.msgbuf", bp, &buflen, NULL, 0) == -1)