handle empty paths

This commit is contained in:
Robin Appelman 2016-01-19 19:39:52 +01:00
commit 83388c4ffc

View file

@ -7,6 +7,7 @@
namespace Icewind\SMB; namespace Icewind\SMB;
use Icewind\SMB\Exception\InvalidPathException;
use Icewind\SMB\Exception\InvalidResourceException; use Icewind\SMB\Exception\InvalidResourceException;
class NativeShare extends AbstractShare { class NativeShare extends AbstractShare {
@ -195,9 +196,13 @@ class NativeShare extends AbstractShare {
* *
* @throws \Icewind\SMB\Exception\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\Exception\InvalidTypeException * @throws \Icewind\SMB\Exception\InvalidTypeException
* @throws \Icewind\SMB\Exception\InvalidPathException
* @throws \Icewind\SMB\Exception\InvalidResourceException * @throws \Icewind\SMB\Exception\InvalidResourceException
*/ */
public function get($source, $target) { public function get($source, $target) {
if (!$target) {
throw new InvalidPathException('Invalid target path: Filename cannot be empty');
}
$targetHandle = @fopen($target, 'wb'); $targetHandle = @fopen($target, 'wb');
if (!$targetHandle) { if (!$targetHandle) {
$error = error_get_last(); $error = error_get_last();