Fix pcre2grep recursive file name length issue.
This commit is contained in:
parent
71d0ee75d2
commit
3a55923da8
|
@ -34,6 +34,11 @@ exit(0) and exit(1).
|
||||||
about a bad option only if the following argument item does not start with a
|
about a bad option only if the following argument item does not start with a
|
||||||
hyphen.
|
hyphen.
|
||||||
|
|
||||||
|
11. pcre2grep was truncating components of file names to 128 characters when
|
||||||
|
processing files with the -r option, and also (some very odd code) truncating
|
||||||
|
path names to 512 characters. There is now a check on the absolute length of
|
||||||
|
full path file names, which may be up to 2047 characters long.
|
||||||
|
|
||||||
|
|
||||||
Version 10.30 14-August-2017
|
Version 10.30 14-August-2017
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
|
@ -109,7 +109,7 @@ typedef int BOOL;
|
||||||
#define MAXPATLEN 8192
|
#define MAXPATLEN 8192
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FNBUFSIZ 1024
|
#define FNBUFSIZ 2048
|
||||||
#define ERRBUFSIZ 256
|
#define ERRBUFSIZ 256
|
||||||
|
|
||||||
/* Values for the "filenames" variable, which specifies options for file name
|
/* Values for the "filenames" variable, which specifies options for file name
|
||||||
|
@ -3032,7 +3032,7 @@ if (isdirectory(pathname))
|
||||||
|
|
||||||
if (dee_action == dee_RECURSE)
|
if (dee_action == dee_RECURSE)
|
||||||
{
|
{
|
||||||
char buffer[1024];
|
char buffer[FNBUFSIZ];
|
||||||
char *nextfile;
|
char *nextfile;
|
||||||
directory_type *dir = opendirectory(pathname);
|
directory_type *dir = opendirectory(pathname);
|
||||||
|
|
||||||
|
@ -3047,7 +3047,13 @@ if (isdirectory(pathname))
|
||||||
while ((nextfile = readdirectory(dir)) != NULL)
|
while ((nextfile = readdirectory(dir)) != NULL)
|
||||||
{
|
{
|
||||||
int frc;
|
int frc;
|
||||||
sprintf(buffer, "%.512s%c%.128s", pathname, FILESEP, nextfile);
|
int fnlength = strlen(pathname) + strlen(nextfile) + 2;
|
||||||
|
if (fnlength > FNBUFSIZ)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "pcre2grep: recursive filename is too long\n");
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
sprintf(buffer, "%s%c%s", pathname, FILESEP, nextfile);
|
||||||
frc = grep_or_recurse(buffer, dir_recurse, FALSE);
|
frc = grep_or_recurse(buffer, dir_recurse, FALSE);
|
||||||
if (frc > 1) rc = frc;
|
if (frc > 1) rc = frc;
|
||||||
else if (frc == 0 && rc == 1) rc = 0;
|
else if (frc == 0 && rc == 1) rc = 0;
|
||||||
|
|
Loading…
Reference in New Issue