Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 Oct 1999 12:45:30 -0600 (MDT)
From:      Marc Slemko <marcs@alive.znep.com>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/14361: locate bogusly converts to network byte order in error messages
Message-ID:  <199910161845.MAA15590@alive.znep.com>

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

>Number:         14361
>Category:       bin
>Synopsis:       locate bogusly converts to network byte order in error messages
>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:   Sat Oct 16 11:50:00 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     Marc Slemko
>Release:        FreeBSD 3.3-STABLE i386
>Organization:
>Environment:

FreeBSD alive.znep.com 3.3-STABLE FreeBSD 3.3-STABLE #1: Sat Oct  2 10:03:23 MDT 1999     marcs@alive.znep.com:/usr/src/sys/compile/ALIVE  i386

>Description:

Locate tries to magically figure out what byte order the locate database
is in.  If the length of a path is not between -MAXPATHLEN and MAXPATHLEN,
it tries converting it from network to host byte order.  If that is
still bogus, it prints an error.  However, it prints the error using the
converted length, which results in something like:

locate: integer out of +-MAXPATHLEN (1024): 100925440

instead of:

locate: integer out of +-MAXPATHLEN (1024): 1030

in the normal case.  I think it is far more reasonble to assume that, if
it doesn't fit network or host byte order, then the host one should
be displayed in the error.  That isn't perfect either, but it is a more
common.  The whole concept of trying to magically figure out what byte
order to use is a bit bogus, but this change makes it so that users don't
see the odd results of it unless they are trying to use a database built
in network byte order.

>How-To-Repeat:

Create a pathname longer than MAXPATHLEN and get it into your locate
database.  Then when locate hits it, it will spit out an error.  

>Fix:
	

Index: util.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/locate/locate/util.c,v
retrieving revision 1.5.2.1
diff -u -r1.5.2.1 util.c
--- util.c	1999/08/29 15:29:53	1.5.2.1
+++ util.c	1999/10/16 18:26:19
@@ -241,7 +241,7 @@
 	if (i > MAXPATHLEN || i < -(MAXPATHLEN)) {
 		i = ntohl(i);
 		if (i > MAXPATHLEN || i < -(MAXPATHLEN))
-			errx(1, "integer out of +-MAXPATHLEN (%d): %d", MAXPATHLEN, i);
+			errx(1, "integer out of +-MAXPATHLEN (%d): %d", MAXPATHLEN, htonl(i));
 	}
 	return(i);
 }
@@ -265,7 +265,7 @@
 	if (word > MAXPATHLEN || word < -(MAXPATHLEN)) {
 		word = ntohl(word);
 		if (word > MAXPATHLEN || word < -(MAXPATHLEN))
-			errx(1, "integer out of +-MAXPATHLEN (%d): %d", MAXPATHLEN, word);
+			errx(1, "integer out of +-MAXPATHLEN (%d): %d", MAXPATHLEN, htonl(word));
 	}
 	return(word);
 }

>Release-Note:
>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?199910161845.MAA15590>