Make FileUitls::Canonicalize return the empty string if it encounters a path with...
commit979b5b312ffbd56126c52f3dcb6cf8fcab89664f
authorNeal Poole <neal@fb.com>
Tue, 1 Mar 2016 00:00:07 +0000 (29 16:00 -0800)
committerHhvm Bot <hhvm-bot-bot@fb.com>
Tue, 1 Mar 2016 00:01:23 +0000 (29 16:01 -0800)
treeb23b3b05010b72e206dec0c678fb7f7aa5af11ab
parenteae73029336e4d577707cb8a0527f22cb8a4588a
Make FileUitls::Canonicalize return the empty string if it encounters a path with a null byte

Summary:In D1837683 the behavior of `File::Open` changed so that we would return null if the provided path contained null. This change was correct as a defense-in-depth technique but it doesn't go far enough: there are a number of places which call `File::TranslatePath` before calling `File::Open`, which leads to the null byte being normalized out.

My change here is to make the code return the empty string from `File::TranslatePath` if we encounter a null-byte. I do that by making `FileUitls::Canonicalize` handle null bytes by returning an empty string. This doesn't directly address functions with null-byte issues, but it may prevent some of them.

Reviewed By: markw65

Differential Revision: D2456626

fb-gh-sync-id: c01275a67c2ef5711a07772f10297af60bcd9548
shipit-source-id: c01275a67c2ef5711a07772f10297af60bcd9548
hphp/runtime/base/file-util.cpp
hphp/test/ext/test_util.cpp