Hello community,

here is the log from the commit of package python-smbprotocol for 
openSUSE:Factory checked in at 2019-12-21 12:29:41
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-smbprotocol (Old)
 and      /work/SRC/openSUSE:Factory/.python-smbprotocol.new.6675 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-smbprotocol"

Sat Dec 21 12:29:41 2019 rev:6 rq:757887 version:1.0.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-smbprotocol/python-smbprotocol.changes    
2019-12-02 11:38:32.810463276 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-smbprotocol.new.6675/python-smbprotocol.changes
  2019-12-21 12:29:44.919316651 +0100
@@ -1,0 +2,10 @@
+Wed Dec 11 20:00:41 UTC 2019 - Martin Hauke <[email protected]>
+
+- Update to version 1.0.1
+  * Fix issue when reading a large file that exceeds 65KB and
+    raises STATUS_END_OF_FILE.
+  * Fix issue where listdir, scandir, walk would only enumerate a
+    subset of entries in a directories with lots of sub files/
+    folders
+
+-------------------------------------------------------------------

Old:
----
  python-smbprotocol-1.0.0.tar.gz

New:
----
  python-smbprotocol-1.0.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-smbprotocol.spec ++++++
--- /var/tmp/diff_new_pack.6X9fO1/_old  2019-12-21 12:29:45.503316928 +0100
+++ /var/tmp/diff_new_pack.6X9fO1/_new  2019-12-21 12:29:45.503316928 +0100
@@ -18,7 +18,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-smbprotocol
-Version:        1.0.0
+Version:        1.0.1
 Release:        0
 Summary:        SMBv2/v3 client for Python 2 and 3
 License:        MIT

++++++ python-smbprotocol-1.0.0.tar.gz -> python-smbprotocol-1.0.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/smbprotocol-1.0.0/CHANGELOG.md 
new/smbprotocol-1.0.1/CHANGELOG.md
--- old/smbprotocol-1.0.0/CHANGELOG.md  2019-11-30 22:31:39.000000000 +0100
+++ new/smbprotocol-1.0.1/CHANGELOG.md  2019-12-11 20:17:38.000000000 +0100
@@ -1,5 +1,11 @@
 # Changelog
 
+## 1.0.1 - 2019-12-12
+
+* Fix issue when reading a large file that exceeds 65KB and raises 
`STATUS_END_OF_FILE`.
+* Fix issue where `listdir`, `scandir`, `walk` would only enumerate a subset 
of entries in a directories with lots of sub files/folders
+
+
 ## 1.0.0 - 2019-11-30
 
 * Dropped support for Python 2.6 and Python 3.4
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/smbprotocol-1.0.0/setup.py 
new/smbprotocol-1.0.1/setup.py
--- old/smbprotocol-1.0.0/setup.py      2019-11-30 22:31:39.000000000 +0100
+++ new/smbprotocol-1.0.1/setup.py      2019-12-11 20:17:38.000000000 +0100
@@ -16,7 +16,7 @@
 
 setup(
     name='smbprotocol',
-    version='1.0.0',
+    version='1.0.1',
     packages=['smbclient', 'smbprotocol'],
     install_requires=[
         'cryptography>=2.0',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/smbprotocol-1.0.0/smbclient/_io.py 
new/smbprotocol-1.0.1/smbclient/_io.py
--- old/smbprotocol-1.0.0/smbclient/_io.py      2019-11-30 22:31:39.000000000 
+0100
+++ new/smbprotocol-1.0.1/smbclient/_io.py      2019-12-11 20:17:38.000000000 
+0100
@@ -414,14 +414,15 @@
         remaining_bytes = self.fd.end_of_file - self._offset
         while len(data) < remaining_bytes or self.FILE_TYPE == 'pipe':
             try:
-                data += self.fd.read(self._offset, self._buffer_size)
+                data_part = self.fd.read(self._offset, self._buffer_size)
             except SMBResponseException as exc:
                 if exc.status == NtStatus.STATUS_PIPE_BROKEN:
                     break
                 raise
 
+            data += data_part
             if self.FILE_TYPE != 'pipe':
-                self._offset += len(data)
+                self._offset += len(data_part)
 
         return data
 
@@ -484,22 +485,19 @@
     _INVALID_MODE = 'w+'
 
     def query_directory(self, pattern, info_class):
-        idx = 0
+        query_flags = QueryDirectoryFlags.SMB2_RESTART_SCANS
         while True:
-            entries = self.fd.query_directory(pattern, info_class, 
flags=QueryDirectoryFlags.SMB2_INDEX_SPECIFIED,
-                                              file_index=idx)
+            try:
+                entries = self.fd.query_directory(pattern, info_class, 
flags=query_flags)
+            except SMBResponseException as exc:
+                if exc.status == NtStatus.STATUS_NO_MORE_FILES:
+                    break
+                raise
 
-            end = False
+            query_flags = 0  # Only the first request should have set 
SMB2_RESTART_SCANS
             for entry in entries:
-                idx = entry['next_entry_offset'].get_value()
-                if idx == 0:
-                    end = True
-
                 yield entry
 
-            if end:
-                break
-
     def readable(self):
         return False
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/smbprotocol-1.0.0/smbprotocol/exceptions.py 
new/smbprotocol-1.0.1/smbprotocol/exceptions.py
--- old/smbprotocol-1.0.0/smbprotocol/exceptions.py     2019-11-30 
22:31:39.000000000 +0100
+++ new/smbprotocol-1.0.1/smbprotocol/exceptions.py     2019-12-11 
20:17:38.000000000 +0100
@@ -49,6 +49,7 @@
     STATUS_NOTIFY_CLEANUP = 0x0000010B
     STATUS_NOTIFY_ENUM_DIR = 0x0000010C
     STATUS_BUFFER_OVERFLOW = 0x80000005
+    STATUS_NO_MORE_FILES = 0x80000006
     STATUS_END_OF_FILE = 0xC0000011
     STATUS_INVALID_EA_NAME = 0x80000013
     STATUS_EA_LIST_INCONSISTENT = 0x80000014
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/smbprotocol-1.0.0/tests/test_smbclient_os.py 
new/smbprotocol-1.0.1/tests/test_smbclient_os.py
--- old/smbprotocol-1.0.0/tests/test_smbclient_os.py    2019-11-30 
22:31:39.000000000 +0100
+++ new/smbprotocol-1.0.1/tests/test_smbclient_os.py    2019-12-11 
20:17:38.000000000 +0100
@@ -554,6 +554,19 @@
         assert fd.read() == b"abc"
 
 
+# https://github.com/jborean93/smbprotocol/issues/20
+def test_read_large_text_file(smb_share):
+    file_path = "%s\\%s" % (smb_share, "file.txt")
+    file_contents = u"a" * 131074
+
+    with smbclient.open_file(file_path, mode='w') as fd:
+        fd.write(file_contents)
+
+    with smbclient.open_file(file_path) as fd:
+        actual = fd.read()
+        assert len(actual) == 131074
+
+
 def test_write_exclusive_text_file(smb_share):
     file_path = "%s\\%s" % (smb_share, "file.txt")
     file_contents = u"File Contents\nNewline"
@@ -1134,6 +1147,26 @@
     assert smbclient.listdir(smb_share) == ['dir']
 
 
+def test_scandir_large(smb_share):
+    dir_path = ntpath.join(smb_share, 'directory')
+
+    # Create lots of directories with the maximum name possible to ensure they 
won't be returned in 1 request.
+    smbclient.mkdir(dir_path)
+    for i in range(150):
+        dirname = str(i).zfill(255)
+        smbclient.mkdir(ntpath.join(smb_share, 'directory', dirname))
+
+    actual = []
+    for entry in smbclient.scandir(dir_path):
+        actual.append(entry.path)
+
+    # Just a test optimisation, remove all the dirs so we don't have to 
re-enumerate them again in rmtree.
+    for path in actual:
+        smbclient.rmdir(path)
+
+    assert len(actual) == 150
+
+
 def test_scandir(smb_share):
     dir_path = ntpath.join(smb_share, 'directory')
     smbclient.makedirs(dir_path, exist_ok=True)


Reply via email to