icewind1991 / SMB

PHP wrapper for smbclient
MIT License
133 stars 54 forks source link

Spaces in folder name #17

Open absentdream opened 9 years ago

absentdream commented 9 years ago

hi. I seem to be having an issue with spaces in folder names, do you have any idea where to start to fix this.. can provide any info requested.

many thanks

absentdream commented 9 years ago

hang on.. its not the space.. (so will dig deeper)

absentdream commented 9 years ago

i am getting memory overload

production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Allowed memory size of 1073741824 bytes exhausted (tried to allocate 32 bytes)' in /srv/www/htdocs/carbon/vendor/icewind/smb/src/RawConnection.php:78

absentdream commented 9 years ago

right i dug deeper and so far found it goes into a endles loop in this.

    /**
     * get all unprocessed output from smbclient until the next prompt
     *
     * @throws ConnectionException
     * @return string
     */
    public function read() {
        if (!$this->isValid()) {
            throw new ConnectionException();
        }
        $line = $this->readLine(); //first line is prompt
        $this->checkConnectionError($line);

        $output = array();
        $line = $this->readLine();
        $length = mb_strlen(self::DELIMITER);
        while (mb_substr($line, 0, $length) !== self::DELIMITER) { //next prompt functions as delimiter
            $output[] .= $line;
            $line = $this->readLine();
        }
        return $output;
    }

it only dose this in certain folders (and is very hard to debug)..i have run the smbclient commands inderpendanlty in command line.

tin:~ # smbclient //hydrogen/MarketingRefInfo -U XXXXXXXXX
Enter XXXXXXXXX password:
Domain=[XXXXXXXXX] OS=[Windows Server 2012 Standard 9200] Server=[Windows Server 2012 Standard 6.2]
smb: \>  cd "_Submissions\PQQ & EOI\_Complete\20120201_Parkside School Submission_A4"
smb: \_Submissions\PQQ & EOI\_Complete\20120201_Parkside School Submission_A4\> dir
  .                                   D        0  Fri Feb 24 08:51:02 2012
  ..                                  D        0  Fri Feb 24 08:51:02 2012
  20120201_Parkside Re-Development_A4 Folder      D        0  Tue May 29 14:40:07 2012
  20120201_Parkside Re-Development_A4highQ.pdf      A  3770199  Thu Feb  2 11:43:12 2012
  20120201_Parkside Re-Development_A4small.pdf      A   671642  Thu Feb  2 11:43:46 2012
  Thumbs.db                         AHS    31744  Tue Apr  3 10:09:33 2012

                59633 blocks of size 33554432. 287 blocks available
smb: \_Submissions\PQQ & EOI\_Complete\20120201_Parkside School Submission_A4\>

and that works so not sure why it goes in endless loop...

any ideas on how to debug?

absentdream commented 9 years ago

ok it seams to be folder path length, i copied it to a folder on the root of the share and slow incressed the folder name length and it errors when the path is over 68 characters long i have fixed/broken/fixed it by varying the folder name length. so now to figure out why :)

icewind1991 commented 9 years ago

@absentdream are you using the latest version? long files names should be fixed with c63516eaed0959b2074a1a594511a409fe3e18a5

absentdream commented 9 years ago

Hi.. I am using "icewind/smb": "dev-master" d311cd3 and have replicated error

i created a long folder name (Stupidly, but thats what users do) "123456789012345678901234567890123456789012345678901234567890123456789" and placed several text docs in it. and it errors

if i shrink the folder name to "12345678901234567890123456789012345678901234567890123456789012345678" it works .. i found this because i was recursively working my way up a folder structure eg "u:\ a folder\and another\more folders\even more\" etc....

many thanks