summaryrefslogtreecommitdiffstats
path: root/usr.bin/locate/locate
diff options
context:
space:
mode:
authormikeh <mikeh@FreeBSD.org>2001-12-12 20:38:07 +0000
committermikeh <mikeh@FreeBSD.org>2001-12-12 20:38:07 +0000
commit53b37471d409cd98e02a24d3938a654aab377d1e (patch)
tree4ebe34485b23934eb336d950519f90285f441f5b /usr.bin/locate/locate
parente231bcb1896b8f1b7ffab6183958ab0496f9c726 (diff)
downloadFreeBSD-src-53b37471d409cd98e02a24d3938a654aab377d1e.zip
FreeBSD-src-53b37471d409cd98e02a24d3938a654aab377d1e.tar.gz
Print the path with the shortest absolute length, rather than
arbitrarily selecting one. PR: bin/14361 Approved by: wosch MFC after: 1 week
Diffstat (limited to 'usr.bin/locate/locate')
-rw-r--r--usr.bin/locate/locate/util.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.bin/locate/locate/util.c b/usr.bin/locate/locate/util.c
index 38fe284..feaa32a 100644
--- a/usr.bin/locate/locate/util.c
+++ b/usr.bin/locate/locate/util.c
@@ -241,7 +241,8 @@ getwm(p)
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, abs(i) < abs(htonl(i)) ? i : htonl(i));
}
return(i);
}
@@ -265,7 +266,9 @@ getwf(fp)
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, abs(word) < abs(htonl(word)) ? word :
+ htonl(word));
}
return(word);
}
OpenPOWER on IntegriCloud