FreeBSD Bugzilla – Attachment 158216 Details for
Bug 201243
locate misses on too large paths
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Enlarge pathsize in locate and it subs
locate.patch (text/plain), 4.13 KB, created by
Willem Jan Withagen
on 2015-07-01 10:29:04 UTC
(
hide
)
Description:
Enlarge pathsize in locate and it subs
Filename:
MIME Type:
Creator:
Willem Jan Withagen
Created:
2015-07-01 10:29:04 UTC
Size:
4.13 KB
patch
obsolete
>Index: usr.bin/locate/bigram/locate.bigram.c >=================================================================== >--- usr.bin/locate/bigram/locate.bigram.c (revision 283928) >+++ usr.bin/locate/bigram/locate.bigram.c (working copy) >@@ -59,11 +59,11 @@ > > #include <stdio.h> > #include <stdlib.h> >-#include <sys/param.h> /* for MAXPATHLEN */ >+#include <sys/param.h> > #include "locate.h" > >-u_char buf1[MAXPATHLEN] = " "; >-u_char buf2[MAXPATHLEN]; >+u_char buf1[LOCPATHLEN] = " "; >+u_char buf2[LOCPATHLEN]; > u_int bigram[UCHAR_MAX + 1][UCHAR_MAX + 1]; > > int >Index: usr.bin/locate/code/locate.code.c >=================================================================== >--- usr.bin/locate/code/locate.code.c (revision 283928) >+++ usr.bin/locate/code/locate.code.c (working copy) >@@ -104,8 +104,8 @@ > > #define BGBUFSIZE (NBG * 2) /* size of bigram buffer */ > >-u_char buf1[MAXPATHLEN] = " "; >-u_char buf2[MAXPATHLEN]; >+u_char buf1[LOCPATHLEN] = " "; >+u_char buf2[LOCPATHLEN]; > u_char bigrams[BGBUFSIZE + 1] = { 0 }; > > #define LOOKUP 1 /* use a lookup array instead a function, 3x faster */ >Index: usr.bin/locate/locate/fastfind.c >=================================================================== >--- usr.bin/locate/locate/fastfind.c (revision 283928) >+++ usr.bin/locate/locate/fastfind.c (working copy) >@@ -50,7 +50,7 @@ > register u_char *p, *s; > register int c; > int count, umlaut; >- u_char bigram1[NBG], bigram2[NBG], path[MAXPATHLEN]; >+ u_char bigram1[NBG], bigram2[NBG], path[LOCPATHLEN]; > > for (c = 0, p = bigram1, s = bigram2; c < NBG; c++) { > p[c] = check_bigram_char(getc(fp)); >@@ -143,7 +143,7 @@ > register int c, cc; > int count, found, globflag; > u_char *cutoff; >- u_char bigram1[NBG], bigram2[NBG], path[MAXPATHLEN]; >+ u_char bigram1[NBG], bigram2[NBG], path[LOCPATHLEN]; > > #ifdef FF_ICASE > /* use a lookup table for case insensitive search */ >@@ -213,7 +213,7 @@ > count += c - OFFSET; > } > >- if (count < 0 || count > MAXPATHLEN) >+ if (count < 0 || count > LOCPATHLEN) > errx(1, "corrupted database: %s", database); > /* overlay old path */ > p = path + count; >Index: usr.bin/locate/locate/locate.h >=================================================================== >--- usr.bin/locate/locate/locate.h (revision 283928) >+++ usr.bin/locate/locate/locate.h (working copy) >@@ -70,3 +70,5 @@ > #define INTSIZE (sizeof(int)) > > #define LOCATE_REG "*?[]\\" /* fnmatch(3) meta characters */ >+ >+#define LOCPATHLEN 2048 >Index: usr.bin/locate/locate/util.c >=================================================================== >--- usr.bin/locate/locate/util.c (revision 283928) >+++ usr.bin/locate/locate/util.c (working copy) >@@ -242,11 +242,11 @@ > > i = u.i; > >- if (i > MAXPATHLEN || i < -(MAXPATHLEN)) { >+ if (i > LOCPATHLEN || i < -(LOCPATHLEN)) { > hi = ntohl(i); >- if (hi > MAXPATHLEN || hi < -(MAXPATHLEN)) >- errx(1, "integer out of +-MAXPATHLEN (%d): %u", >- MAXPATHLEN, abs(i) < abs(hi) ? i : hi); >+ if (hi > LOCPATHLEN || hi < -(LOCPATHLEN)) >+ errx(1, "integer out of +-LOCPATHLEN (%d): %u", >+ LOCPATHLEN, abs(i) < abs(hi) ? i : hi); > return(hi); > } > return(i); >@@ -268,11 +268,11 @@ > > word = getw(fp); > >- if (word > MAXPATHLEN || word < -(MAXPATHLEN)) { >+ if (word > LOCPATHLEN || word < -(LOCPATHLEN)) { > hword = ntohl(word); >- if (hword > MAXPATHLEN || hword < -(MAXPATHLEN)) >- errx(1, "integer out of +-MAXPATHLEN (%d): %u", >- MAXPATHLEN, abs(word) < abs(hword) ? word : hword); >+ if (hword > LOCPATHLEN || hword < -(LOCPATHLEN)) >+ errx(1, "integer out of +-LOCPATHLEN (%d): %u", >+ LOCPATHLEN, abs(word) < abs(hword) ? word : hword); > return(hword); > } > return(word); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 201243
: 158216