Skip to content

Commit

Permalink
Fix buffer overflow in glob()
Browse files Browse the repository at this point in the history
Summary:
glob() needs the directory to be less than PATH_MAX

Test Plan:
make
make fast_tests

DiffCamp Revision: 162960
Reviewed By: hzhao
CC: hzhao, hphp-diffs@lists
Revert Plan:
Ok
  • Loading branch information
Scott MacVicar committed Dec 7, 2011
1 parent abacd5a commit 70aac14
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/runtime/ext/ext_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,12 @@ Variant f_glob(CStrRef pattern, int flags /* = 0 */) {
globbuf.gl_offs = 0;
String work_pattern;

if (pattern.size() >= PATH_MAX) {
raise_warning("Pattern exceeds the maximum allowed length of %d characters",
PATH_MAX);
return false;
}

if (pattern.charAt(0) == '/') {
work_pattern = pattern;
} else {
Expand Down

0 comments on commit 70aac14

Please sign in to comment.