From 6e3650edd3cbdd9f29be4e8fa9ec9cd307f178e7 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 27 Aug 2013 09:41:13 +0000 Subject: [PATCH] torture: Add buffercheck tests Make sure we get the smb2 infolevel fixed portions right I could not find correct #defines for the infolevels Bug: https://bugzilla.samba.org/show_bug.cgi?id=10106 Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Thu Aug 29 01:27:11 CEST 2013 on sn-devel-104 --- selftest/knownfail | 3 + source4/torture/smb2/getinfo.c | 244 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 229 insertions(+), 18 deletions(-) diff --git a/selftest/knownfail b/selftest/knownfail index dd536df57af..6fe7ce5c01f 100644 --- a/selftest/knownfail +++ b/selftest/knownfail @@ -171,6 +171,9 @@ ^samba4.smb2.oplock.batch20\(.*\)$ # samba 4 oplocks are a mess ^samba4.smb2.oplock.stream1 # samba 4 oplocks are a mess ^samba4.smb2.getinfo.complex # streams on directories does not work +^samba4.smb2.getinfo.qfs_buffercheck # S4 does not do the INFO_LENGTH_MISMATCH/BUFFER_OVERFLOW thingy +^samba4.smb2.getinfo.qfile_buffercheck # S4 does not do the INFO_LENGTH_MISMATCH/BUFFER_OVERFLOW thingy +^samba4.smb2.getinfo.qsec_buffercheck # S4 does not do the BUFFER_TOO_SMALL thingy ^samba4.ntvfs.cifs.krb5.base.createx_access.createx_access\(.*\)$ ^samba4.rpc.lsa.forest.trust #Not fully provided by Samba4 ^samba4.blackbox.kinit\(.*\).kinit with user password for expired password\(.*\) # We need to work out why this fails only during the pw change diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c index 10dd550cdd4..fafc36c31de 100644 --- a/source4/torture/smb2/getinfo.c +++ b/source4/torture/smb2/getinfo.c @@ -22,9 +22,11 @@ #include "includes.h" #include "libcli/smb2/smb2.h" #include "libcli/smb2/smb2_calls.h" +#include "libcli/smb/smbXcli_base.h" #include "torture/torture.h" #include "torture/smb2/proto.h" +#include "torture/util.h" static struct { const char *name; @@ -154,41 +156,243 @@ static bool torture_smb2_fsinfo(struct torture_context *tctx) return true; } +static bool torture_smb2_buffercheck_err(struct torture_context *tctx, + struct smb2_tree *tree, + struct smb2_getinfo *b, + size_t fixed, + DATA_BLOB full) +{ + size_t i; -/* - test for buffer size handling -*/ -static bool torture_smb2_buffercheck(struct torture_context *tctx) + for (i=0; i<=full.length; i++) { + NTSTATUS status; + + b->in.output_buffer_length = i; + + status = smb2_getinfo(tree, tree, b); + + if (i < fixed) { + torture_assert_ntstatus_equal( + tctx, status, NT_STATUS_INFO_LENGTH_MISMATCH, + "Wrong error code small buffer"); + continue; + } + + if (iout.blob.data); + continue; + } + + torture_assert_ntstatus_equal( + tctx, status, NT_STATUS_OK, + "Wrong error code for right sized buffer"); + } + + return true; +} + +struct level_buffersize { + int level; + size_t fixed; +}; + +static bool torture_smb2_qfs_buffercheck(struct torture_context *tctx) { bool ret; struct smb2_tree *tree; NTSTATUS status; struct smb2_handle handle; - struct smb2_getinfo b; + int i; + + struct level_buffersize levels[] = { + { 1, 24 }, /* We don't have proper defines here */ + { 3, 24 }, + { 4, 8 }, + { 5, 16 }, + { 6, 48 }, + { 7, 32 }, + { 11, 28 }, + }; - printf("Testing buffer size handling\n"); + printf("Testing SMB2_GETINFO_FS buffer sizes\n"); ret = torture_smb2_connection(tctx, &tree); torture_assert(tctx, ret, "connection failed"); status = smb2_util_roothandle(tree, &handle); - torture_assert_ntstatus_ok(tctx, status, "Unable to create root handle"); + torture_assert_ntstatus_ok( + tctx, status, "Unable to create root handle"); + + for (i=0; i