From e99ee98ab1a832c399d1990561c3f66616ed6606 Mon Sep 17 00:00:00 2001 From: Ryan Doherty <3150510+rsdoherty@users.noreply.github.com> Date: Wed, 1 Nov 2023 23:04:27 +0000 Subject: [PATCH] Add 0xc000007f to mapping (#245) * Add 0xc000007f to mapping * Use STATUS_DISK_FULL, not STATUS_LOW_DISK_SPACE * Use DiskFull, not NotEnoughSpaceOnTheDisk * Remove comment --- src/smbprotocol/exceptions.py | 5 +++++ src/smbprotocol/header.py | 1 + tests/test_exceptions.py | 15 +++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/src/smbprotocol/exceptions.py b/src/smbprotocol/exceptions.py index 8508eed0..9bcd49d1 100644 --- a/src/smbprotocol/exceptions.py +++ b/src/smbprotocol/exceptions.py @@ -612,6 +612,11 @@ class ServerUnavailable(SMBResponseException): _STATUS_CODE = NtStatus.STATUS_SERVER_UNAVAILABLE +class DiskFull(SMBResponseException): + _BASE_MESSAGE = "There is not enough space on the disk." + _STATUS_CODE = NtStatus.STATUS_DISK_FULL + + class ErrorContextId: """ [MS-SMB2] v53.0 2017-09-15 diff --git a/src/smbprotocol/header.py b/src/smbprotocol/header.py index fb3a0301..269d07ab 100644 --- a/src/smbprotocol/header.py +++ b/src/smbprotocol/header.py @@ -108,6 +108,7 @@ class NtStatus: STATUS_DFS_UNAVAILABLE = 0xC000026D STATUS_NOT_A_REPARSE_POINT = 0xC0000275 STATUS_SERVER_UNAVAILABLE = 0xC0000466 + STATUS_DISK_FULL = 0xC000007F class Smb2Flags: diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index f4795b6b..92cb159b 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -126,6 +126,21 @@ def test_throw_default_exception(self): assert str(exc) == exp_resp assert exc.status == NtStatus.STATUS_INVALID_PARAMETER + def test_throw_low_disk(self): + error_resp = SMB2ErrorResponse() + header = self._get_header(error_resp, NtStatus.STATUS_DISK_FULL) + try: + raise SMBResponseException(header) + except SMBResponseException as exc: + assert exc.error_details == [] + exp_resp = ( + "Received unexpected status from the server: There is not enough space on the disk. " + "(3221225599) STATUS_DISK_FULL: 0xc000007f" + ) + assert exc.message == exp_resp + assert str(exc) == exp_resp + assert exc.status == NtStatus.STATUS_DISK_FULL + def test_throw_exception_without_header(self): actual = NetworkNameDelegated() assert isinstance(actual, NetworkNameDelegated)