1

I think I may have a Heisenbug on my hands. My code so far looks like this:

$enc = $_REQUEST['l'];
$filename = DecryptString($enc);

echo $filename;  //Displays: uploads/Maid with the Flaxen Hair.mp3


if (is_dir($filename))  //Gives the error: "Warning: is_dir() expects parameter 1 to be a valid path, string given"
{

    Download($filename);
}

However, if I take what as echo'ed earlier, which was uploads/Maid with the Flaxen Hair.mp3, and run is_dir("uploads/Maid with the Flaxen Hair.mp3"), it returns as expected.

So if I pass the variable into is_dir, it fails, but if I pass the value of the variable it works. What's the catch?

ivan_pozdeev
  • 33,874
  • 19
  • 107
  • 152
Barbacamanitu
  • 61
  • 1
  • 4

1 Answers1

2

DecryptString() is returning a string with NULs (\0) at the end.

Make sure you trim them off before trying to use the value.

You can trim the NULL character with $enc = trim($enc);

Bijan
  • 7,737
  • 18
  • 89
  • 149
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358