Bug 5826 - Directory/Filenames get truncated when 3.2.0 client acesses old server
Summary: Directory/Filenames get truncated when 3.2.0 client acesses old server
Status: RESOLVED FIXED
Alias: None
Product: Samba 3.2
Classification: Unclassified
Component: libsmbclient (show other bugs)
Version: 3.2.0
Hardware: x86 Linux
: P3 normal
Target Milestone: ---
Assignee: Jeremy Allison
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-16 09:11 UTC by Peter Ries
Modified: 2009-02-01 10:18 UTC (History)
2 users (show)

See Also:


Attachments
Patch for 3.2 (779 bytes, patch)
2008-10-16 13:57 UTC, Jeremy Allison
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Ries 2008-10-16 09:11:09 UTC
I opened this bug @ debian under 
 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=495081
The maintainer suggested to talk to upstream, but as I don't know if he would do that or I should, I herewith open a bug in your bugtracking system.

Here's a copy & paste of my error:

-------start--------
Package: smbclient
Version: 2:3.2.0-4 

I upgraded my testing-debian on August 1st with aptitude update /
upgrade. 
With this upgrade the smbclient package (samba, samba-common too) was
updated from 2:3.0.28 to 2:3.2.0-4.

I have a tiny Asus-WLHDD NAS with a modified Linux-Firmware and an old
Samba Server Version running there. 
While Windows XP workstations can still access the Samba Server, my
debian workstation fails since the update.

Typing smb://wlhdd/sharename returns an error (saying directory xy does
not exist, which is correct as it's name is xyz...) and afterwards the
content is displayed with every entry truncated by the last character.

Example 1 - show my shares:

peter@pc02:~$ smbclient -L //wlhdd/
Enter peter's password:
Domain=[ASUSWLHDD] OS=[Unix] Server=[Samba 2.0.10-security-rollup]

        Sharename       Type      Comment
        ---------       ----      -------
        artists         Disk
        mixe            Disk
        singles         Disk
        IPC$            IPC       IPC Service (Samba
2.0.10-security-rollup)
Domain=[ASUSWLHDD] OS=[Unix] Server=[Samba 2.0.10-security-rollup]

        Server               Comment
        ---------            -------
        PC02                 peter02 server
        WLHDD                Samba 2.0.10-security-rollup

        Workgroup            Master
        ---------            -------
        ASUSWLHDD            WLHDD 



Example 2 - accessing content:

smbclient //wlhdd/Artists
Enter peter's password:
Domain=[ASUSWLHDD] OS=[Unix] Server=[Samba 2.0.10-security-rollup]
smb: \> ls
                                      D        0  Sat Nov 24 20:05:07 2007
  .                                   D        0  Fri Nov 23 07:35:13 2007
  Jamiroqua                           D        0  Sun Feb  4 13:13:38 2007
  Corinne Bailey Ra                   D        0  Sun Feb  4 12:41:16 2007
  Norah Jone                          D        0  Sun Feb  4 13:45:56 2007
  Katie Melu                          D        0  Sun Feb  4 13:20:22 2007

                56306 blocks of size 2097152. 18124 blocks available
smb: \>                                        


As you can see the Server runs a 2.0.10 Version of Samba.

Googling around I found two similar Bugs (and a possible solution) in
RedHat's Bugzilla:

1)  https://bugzilla.redhat.com/show_bug.cgi?id=446657 
2)  https://bugzilla.redhat.com/show_bug.cgi?id=443047 

May be these links are helpful.

-----ANSWER of MAINTAINER-----
The "possible solution" appears to be:
  https://bugzilla.redhat.com/show_bug.cgi?id=446657#c2

I'm afraid I'm not willing to make such a change without upstream's sign-off
(since if the change is wrong in any way it's a potential buffer overflow),
and I definitely don't have any servers of this vintage to test against
(samba 2.2 is woody era, i.e. oldstable-1).  I would suggest talking to
upstream about this bug.

-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
slangasek@ubuntu.com                                     vorlon@debian.org



-------end----------
Comment 1 Jeremy Allison 2008-10-16 12:28:14 UTC
Ok, I'll fire up a server of that vintage and try and reproduce/fix.
Thanks for the report.
Jeremy.
Comment 2 Jeremy Allison 2008-10-16 13:57:37 UTC
Created attachment 3678 [details]
Patch for 3.2

There was some code in pull_ucs2_base_talloc() to cope with this case which hadn't been added to pull_ascii_base_talloc(). The older Samba returns non unicode names which is why you are seeing this codepath being executed.

Jeremy.
Comment 3 Don Marti 2008-12-09 18:50:15 UTC
This bug also shows up with a Buffalo Terastation which I have access to and can test on if you want.  Last character of directory and file names is truncated but if you know the last character of a directory name you can "cd" to it in smbclient.  Server identifies itself as:

Domain=[*************] OS=[Unix] Server=[Samba 2.2.8a-ja-1.1]

$ smbclient --version
Version 3.2.5

(The share mounts fine with mount -t cifs.)
Comment 4 Jeremy Allison 2008-12-09 18:55:25 UTC
I'm pretty sure the patch I added fixes this problem. Will be fixed in 3.2.6 (due this week or so).
Jeremy.
Comment 5 Jelmer Vernooij 2009-02-01 10:18:35 UTC
Confirmed fixed by the reporter in LP #282298 / Debian #495081, via Bubulle.