Bug 7729 - Typo in stream_depot VFS module leads to NT_STATUS_INVALID_PARAMETER error on basic test
Summary: Typo in stream_depot VFS module leads to NT_STATUS_INVALID_PARAMETER error on...
Status: RESOLVED INVALID
Alias: None
Product: Samba 3.5
Classification: Unclassified
Component: VFS Modules (show other bugs)
Version: 3.5.6
Hardware: x64 Linux
: P3 normal
Target Milestone: ---
Assignee: Samba Bugzilla Account
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-14 10:08 UTC by Volodymyr Khomenko (dead mail address)
Modified: 2010-10-19 07:36 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volodymyr Khomenko (dead mail address) 2010-10-14 10:08:21 UTC
I've switched ON stream_depot module and did following basic test of ADS:

>echo DATA > \\samba_srv\share\volodymyr_ADS_test.txt
>echo S1 > \\samba_srv\share\volodymyr_ADS_test.txt::S1
The parameter is incorrect

I've investigated the code and seen that the reason of this error is the check for default stream (::$DATA) in stream_smb_fname(). AFAIU this function shouldn't be called with default stream name and such check prevents from this. BUT due the ?typo? check is inverted and only default stream name is accepted, real streams are prohibited.

If by guess is correct, the following patch should be applied:
--- source3/modules/vfs_streams_depot.c
+++ source3/modules/vfs_streams_depot.c
@@ -322,7 +322,7 @@ static NTSTATUS stream_smb_fname(vfs_han
    stype = strchr_m(smb_fname->stream_name + 1, ':');

    if (stype) {
-       if (StrCaseCmp(stype, ":$DATA") != 0) {
+       if (StrCaseCmp(stype, ":$DATA") == 0) {
            return NT_STATUS_INVALID_PARAMETER;
        }
    }


Appropriate samba log is following:

[2010/10/14 15:59:46.604667, 10, pid=1647] smbd/nttrans.c:498(reply_ntcreate_and_X)
  reply_ntcreate_and_X: flags = 0x16, access_mask = 0x20196 file_attributes = 0x80, share_access = 0x1, create_disposition = 0
x5 create_options = 0x40 root_dir_fid = 0x0, fname = volodymyr_ADS_test.txt::S1
[2010/10/14 15:59:46.604706,  5, pid=1647] smbd/filename.c:169(unix_convert)
  unix_convert called on file "volodymyr_ADS_test.txt::S1"
[2010/10/14 15:59:46.604724,  5, pid=1647] smbd/filename.c:328(unix_convert)
  unix_convert begin: name = volodymyr_ADS_test.txt, dirpath = , start = volodymyr_ADS_test.txt
[2010/10/14 15:59:46.604843, 10, pid=1647] modules/vfs_streams_depot.c:469(streams_depot_stat)
  streams_depot_stat called for [volodymyr_ADS_test.txt]
[2010/10/14 15:59:46.605128,  5, pid=1647] smbd/filename.c:351(unix_convert)
  conversion of base_name finished volodymyr_ADS_test.txt::S1 -> volodymyr_ADS_test.txt
[2010/10/14 15:59:46.605148, 10, pid=1647] modules/vfs_streams_depot.c:469(streams_depot_stat)
  streams_depot_stat called for [volodymyr_ADS_test.txt::S1]
[2010/10/14 15:59:46.605173, 10, pid=1647] lib/errmap_unix.c:259(map_errno_from_nt_status)
  map_errno_from_nt_status: 32 bit codes: code=c000000d
[2010/10/14 15:59:46.605192, 10, pid=1647] smbd/filename.c:1041(build_stream_path)
  vfs_stat failed: Invalid argument
[2010/10/14 15:59:46.605214, 10, pid=1647] smbd/filename.c:817(unix_convert)
  dirpath = [] start = [volodymyr_ADS_test.txt]
[2010/10/14 15:59:46.605226, 10, pid=1647] smbd/filename.c:1172(filename_convert)
  filename_convert: unix_convert failed for name volodymyr_ADS_test.txt::S1 with NT_STATUS_INVALID_PARAMETER
[2010/10/14 15:59:46.605240,  3, pid=1647] smbd/error.c:80(error_packet_set)
  error packet at smbd/nttrans.c(550) cmd=162 (SMBntcreateX) NT_STATUS_INVALID_PARAMETER
Comment 1 Volodymyr Khomenko (dead mail address) 2010-10-19 07:36:52 UTC
My bad, the test was invalid (must use single colon to specify stream name).
Samba detects invalid stream type and properly reports the error.