From 4c6c71e1378401d66bf2ed230544a75f7b04376f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 14 Jan 2021 17:32:15 +0100 Subject: [PATCH] libcli/smb: allow unexpected padding in SMB2 IOCTL responses A NetApp Ontap 7.3.7 SMB server add 8 padding bytes to an offset that's already 8 byte aligned. RN: Work around special SMB2 IOCTL response behavior of NetApp Ontap 7.3.7 BUG: https://bugzilla.samba.org/show_bug.cgi?id=14607 Pair-Programmed-With: Volker Lendecke Signed-off-by: Stefan Metzmacher Signed-off-by: Volker Lendecke Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Fri Jan 15 08:36:34 UTC 2021 on sn-devel-184 --- libcli/smb/smb2cli_ioctl.c | 19 ++++++++++++++++++- .../knownfail.d/samba3.smb2.ioctl.bug14607 | 1 - 2 files changed, 18 insertions(+), 2 deletions(-) delete mode 100644 selftest/knownfail.d/samba3.smb2.ioctl.bug14607 diff --git a/libcli/smb/smb2cli_ioctl.c b/libcli/smb/smb2cli_ioctl.c index 6368bd31bc2..f9abcc57bab 100644 --- a/libcli/smb/smb2cli_ioctl.c +++ b/libcli/smb/smb2cli_ioctl.c @@ -191,8 +191,25 @@ static NTSTATUS smb2cli_ioctl_parse_buffer(uint32_t dyn_offset, return NT_STATUS_OK; } + if ((buffer_offset % 8) != 0) { + /* + * The offset needs to be 8 byte aligned. + */ + return NT_STATUS_INVALID_NETWORK_RESPONSE; + } + + /* + * We used to enforce buffer_offset to be + * an exact match of the expected minimum, + * but the NetApp Ontap 7.3.7 SMB server + * gets the padding wrong and aligns the + * input_buffer_offset by a value of 8. + * + * So we just enforce that the offset is + * not lower than the expected value. + */ SMB_ASSERT(min_offset >= dyn_offset); - if (buffer_offset != min_offset) { + if (buffer_offset < min_offset) { return NT_STATUS_INVALID_NETWORK_RESPONSE; } diff --git a/selftest/knownfail.d/samba3.smb2.ioctl.bug14607 b/selftest/knownfail.d/samba3.smb2.ioctl.bug14607 deleted file mode 100644 index c535a8a2723..00000000000 --- a/selftest/knownfail.d/samba3.smb2.ioctl.bug14607 +++ /dev/null @@ -1 +0,0 @@ -^samba3.smb2.ioctl.*bug14607.nt4_dc