Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Jun 1998 01:22:41 -0500 (CDT)
From:      fullermd@mortis.futuresouth.com
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/6963: msgs -p can give misleading errors
Message-ID:  <199806160622.BAA04865@mortis.futuresouth.com>

next in thread | raw e-mail | index | archive | help

>Number:         6963
>Category:       bin
>Synopsis:       msgs -p can give misleading errors
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 15 23:30:00 PDT 1998
>Last-Modified:
>Originator:     Matthew Fuller
>Organization:
>Release:        FreeBSD 2.2.6-STABLE i386
>Environment:

	This is again rev. 1.9 of msgs.c, but I don't think there's that much
	difference betweeen it and 1.8.2.1.

>Description:

	msgs -p (and maybe other flags, too) gives misleading error messages,
	especially on a new install, where /var/msgs/bounds doesn't exist.  I
	moved my bounds file out of the way to create this before and after
	on a quick 'n' dirty hack, which is probably the 23rd best way to do it,
	but it works:
	
{~/work/freebsd-hacks} mortis:{325} %msgs -p
msgs: /var/msgs/bounds: Permission denied
{~/work/freebsd-hacks} mortis:{326} %./msgs -p
/var/msgs/bounds: No such file or directory


>How-To-Repeat:

	Have no /var/msgs/bounds file and run msgs -p

>Fix:
	

--- msgs.c.orig	Tue Jun 16 00:46:04 1998
+++ msgs.c	Tue Jun 16 01:12:42 1998
@@ -169,6 +169,7 @@
 	int rcback = 0;			/* amount to back off of rcfirst */
 	int firstmsg = 0, nextmsg = 0, lastmsg = 0;
 	int blast = 0;
+	struct stat buf;		/* stat to check access of bounds */
 	FILE *bounds;
 
 #ifdef UNBUFFERED
@@ -244,6 +245,11 @@
 	 * determine current message bounds
 	 */
 	snprintf(fname, sizeof(fname), "%s/%s", _PATH_MSGS, BOUNDS);
+	if (stat(fname, &buf) < 0)
+	{
+		perror(fname);
+		exit(1);
+	}
 	bounds = fopen(fname, "r");
 
 	if (bounds != NULL) {
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



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