From owner-svn-src-head@FreeBSD.ORG Fri Feb 6 00:50:21 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D89F8106566C; Fri, 6 Feb 2009 00:50:21 +0000 (UTC) (envelope-from wkoszek@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C67748FC13; Fri, 6 Feb 2009 00:50:21 +0000 (UTC) (envelope-from wkoszek@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n160oLpg044186; Fri, 6 Feb 2009 00:50:21 GMT (envelope-from wkoszek@svn.freebsd.org) Received: (from wkoszek@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n160oLBS044185; Fri, 6 Feb 2009 00:50:21 GMT (envelope-from wkoszek@svn.freebsd.org) Message-Id: <200902060050.n160oLBS044185@svn.freebsd.org> From: "Wojciech A. Koszek" Date: Fri, 6 Feb 2009 00:50:21 +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: r188214 - head/usr.sbin/config X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Feb 2009 00:50:22 -0000 Author: wkoszek Date: Fri Feb 6 00:50:21 2009 New Revision: 188214 URL: http://svn.freebsd.org/changeset/base/188214 Log: Make config -x only return non-zero characters, so that: config -x | grep just works. Reported by: Danny Braniss Modified: head/usr.sbin/config/main.c Modified: head/usr.sbin/config/main.c ============================================================================== --- head/usr.sbin/config/main.c Fri Feb 6 00:48:56 2009 (r188213) +++ head/usr.sbin/config/main.c Fri Feb 6 00:50:21 2009 (r188214) @@ -669,7 +669,7 @@ kernconfdump(const char *file) struct stat st; FILE *fp, *pp; int error, len, osz, r; - unsigned int off, size; + unsigned int i, off, size; char *cmd, *o; r = open(file, O_RDONLY); @@ -707,7 +707,18 @@ kernconfdump(const char *file) r = fseek(fp, off, SEEK_CUR); if (r != 0) errx(EXIT_FAILURE, "fseek() failed"); - while ((r = fgetc(fp)) != EOF && size-- > 0) + for (i = 0; i < size - 1; i++) { + r = fgetc(fp); + if (r == EOF) + break; + /* + * If '\0' is present in the middle of the configuration + * string, this means something very weird is happening. + * Make such case very visible. + */ + assert(r != '\0' && ("Char present in the configuration " + "string mustn't be equal to 0")); fputc(r, stdout); + } fclose(fp); }