Skip to content

Commit

Permalink
Fix pcregrep recursive file name issue.
Browse files Browse the repository at this point in the history
git-svn-id: svn:https://vcs.exim.org/pcre/code/trunk@1712 2f5784b3-3f2a-0410-8824-cb99058d5e15
  • Loading branch information
ph10 committed Oct 20, 2017
1 parent 3f00c92 commit 49b9fc5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Version 8.42 xx-xxx-2017

2. Fixed outdated real_pcre definitions in pcre.h.in (patch by Evgeny Kotkov).

3. pcregrep 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 8.41 05-July-2017
-------------------------
Expand Down
10 changes: 8 additions & 2 deletions pcregrep.c
Original file line number Diff line number Diff line change
Expand Up @@ -2234,7 +2234,7 @@ if (isdirectory(pathname))

if (dee_action == dee_RECURSE)
{
char buffer[1024];
char buffer[2048];
char *nextfile;
directory_type *dir = opendirectory(pathname);

Expand All @@ -2249,7 +2249,13 @@ if (isdirectory(pathname))
while ((nextfile = readdirectory(dir)) != NULL)
{
int frc;
sprintf(buffer, "%.512s%c%.128s", pathname, FILESEP, nextfile);
int fnlength = strlen(pathname) + strlen(nextfile) + 2;
if (fnlength > 2048)
{
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);
if (frc > 1) rc = frc;
else if (frc == 0 && rc == 1) rc = 0;
Expand Down

0 comments on commit 49b9fc5

Please sign in to comment.