diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-11-20 10:29:54 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-11-20 10:29:54 +0000 |
commit | d4dfcda78eeca4206965667a45f4f00f4e10457a (patch) | |
tree | 952f96c7eef52ad28609d65eef4cb37b1002e191 | |
parent | 5d77cda1dccf79356aa8ab3ef3516aa69325e2be (diff) | |
download | samba-d4dfcda78eeca4206965667a45f4f00f4e10457a.tar.gz samba-d4dfcda78eeca4206965667a45f4f00f4e10457a.tar.bz2 samba-d4dfcda78eeca4206965667a45f4f00f4e10457a.zip |
* fixed level2 of QueryUserInfo
* added per-field testing of SetUserInfo
* fixed strlen_m()
(This used to be commit 26238b0f8a5752bb0f611c4aa492b964e419209a)
-rw-r--r-- | source4/lib/util_str.c | 9 | ||||
-rw-r--r-- | source4/librpc/idl/samr.idl | 3 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_atsvc.c | 2 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_dfs.c | 16 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_echo.c | 4 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_lsa.c | 18 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_misc.c | 12 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_samr.c | 31 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_samr.h | 3 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_spoolss.c | 4 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_srvsvc.c | 40 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_wkssvc.c | 2 | ||||
-rw-r--r-- | source4/torture/rpc/samr.c | 104 |
13 files changed, 223 insertions, 25 deletions
diff --git a/source4/lib/util_str.c b/source4/lib/util_str.c index b220820104..285b0cc02e 100644 --- a/source4/lib/util_str.c +++ b/source4/lib/util_str.c @@ -1074,13 +1074,18 @@ size_t strlen_m(const char *s) { size_t count = 0; + if (!s) { + return 0; + } + while (*s && !(((unsigned char)s[0]) & 0x7F)) { s++; count++; } - if (!*s) - return; + if (!*s) { + return count; + } push_ucs2(NULL,tmpbuf,s, sizeof(tmpbuf), STR_TERMINATE); return count + strlen_w(tmpbuf); diff --git a/source4/librpc/idl/samr.idl b/source4/librpc/idl/samr.idl index 219745513c..55c377dbcc 100644 --- a/source4/librpc/idl/samr.idl +++ b/source4/librpc/idl/samr.idl @@ -457,8 +457,7 @@ typedef struct { samr_Name comment; - uint32 unknown1; - uint32 unknown2; + samr_Name unknown; /* settable, but doesn't stick. probably obsolete */ uint16 country_code; uint16 code_page; } samr_UserInfo2; diff --git a/source4/librpc/ndr/ndr_atsvc.c b/source4/librpc/ndr/ndr_atsvc.c index 76255b44d7..d502add2b0 100644 --- a/source4/librpc/ndr/ndr_atsvc.c +++ b/source4/librpc/ndr/ndr_atsvc.c @@ -204,8 +204,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->first_entry, r->entries_read, sizeof(r->first_entry[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->first_entry, sizeof(r->first_entry[0]), r->entries_read, (ndr_pull_flags_fn_t)ndr_pull_atsvc_JobEnumInfo)); } + } done: return NT_STATUS_OK; } diff --git a/source4/librpc/ndr/ndr_dfs.c b/source4/librpc/ndr/ndr_dfs.c index 626cfc5789..d6a6679700 100644 --- a/source4/librpc/ndr/ndr_dfs.c +++ b/source4/librpc/ndr/ndr_dfs.c @@ -598,8 +598,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->stores, r->num_stores, sizeof(r->stores[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->stores, sizeof(r->stores[0]), r->num_stores, (ndr_pull_flags_fn_t)ndr_pull_dfs_StorageInfo)); } + } done: return NT_STATUS_OK; } @@ -653,8 +655,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->stores, r->num_stores, sizeof(r->stores[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->stores, sizeof(r->stores[0]), r->num_stores, (ndr_pull_flags_fn_t)ndr_pull_dfs_StorageInfo)); } + } done: return NT_STATUS_OK; } @@ -953,8 +957,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->s, r->count, sizeof(r->s[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->s, sizeof(r->s[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_dfs_Info1)); } + } done: return NT_STATUS_OK; } @@ -984,8 +990,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->s, r->count, sizeof(r->s[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->s, sizeof(r->s[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_dfs_Info2)); } + } done: return NT_STATUS_OK; } @@ -1015,8 +1023,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->s, r->count, sizeof(r->s[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->s, sizeof(r->s[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_dfs_Info3)); } + } done: return NT_STATUS_OK; } @@ -1046,8 +1056,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->s, r->count, sizeof(r->s[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->s, sizeof(r->s[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_dfs_Info4)); } + } done: return NT_STATUS_OK; } @@ -1077,8 +1089,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->s, r->count, sizeof(r->s[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->s, sizeof(r->s[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_dfs_Info200)); } + } done: return NT_STATUS_OK; } @@ -1108,8 +1122,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->s, r->count, sizeof(r->s[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->s, sizeof(r->s[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_dfs_Info300)); } + } done: return NT_STATUS_OK; } diff --git a/source4/librpc/ndr/ndr_echo.c b/source4/librpc/ndr/ndr_echo.c index b3ec408b2d..9ddc64354a 100644 --- a/source4/librpc/ndr/ndr_echo.c +++ b/source4/librpc/ndr/ndr_echo.c @@ -73,8 +73,10 @@ NTSTATUS ndr_pull_echo_EchoData(struct ndr_pull *ndr, struct echo_EchoData *r) } } NDR_ALLOC_N_SIZE(ndr, r->out.out_data, r->in.len, sizeof(r->out.out_data[0])); + { NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.out_data, r->in.len)); } + } return NT_STATUS_OK; } @@ -95,8 +97,10 @@ NTSTATUS ndr_pull_echo_SourceData(struct ndr_pull *ndr, struct echo_SourceData * return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should be %u", _array_size, r->in.len); } } + { NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.data, r->in.len)); } + } return NT_STATUS_OK; } diff --git a/source4/librpc/ndr/ndr_lsa.c b/source4/librpc/ndr/ndr_lsa.c index 2ed6b89e7b..b246fbc170 100644 --- a/source4/librpc/ndr/ndr_lsa.c +++ b/source4/librpc/ndr/ndr_lsa.c @@ -592,8 +592,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->privs, r->count, sizeof(r->privs[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->privs, sizeof(r->privs[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_lsa_PrivEntry)); } + } done: return NT_STATUS_OK; } @@ -714,8 +716,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->settings, r->count, sizeof(r->settings[0])); + { NDR_CHECK(ndr_pull_array_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->settings, r->count)); } + } done: return NT_STATUS_OK; } @@ -1083,8 +1087,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->sids, r->num_sids, sizeof(r->sids[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->sids, sizeof(r->sids[0]), r->num_sids, (ndr_pull_flags_fn_t)ndr_pull_lsa_SidPtr)); } + } done: return NT_STATUS_OK; } @@ -1154,8 +1160,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->domains, r->count, sizeof(r->domains[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->domains, sizeof(r->domains[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_lsa_DomainInformation)); } + } done: return NT_STATUS_OK; } @@ -1209,8 +1217,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->sids, r->count, sizeof(r->sids[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->sids, sizeof(r->sids[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_lsa_TranslatedSid)); } + } done: return NT_STATUS_OK; } @@ -1265,8 +1275,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->domains, r->count, sizeof(r->domains[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->domains, sizeof(r->domains[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_lsa_TrustInformation)); } + } done: return NT_STATUS_OK; } @@ -1331,8 +1343,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->names, r->count, sizeof(r->names[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->names, sizeof(r->names[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_lsa_TranslatedName)); } + } done: return NT_STATUS_OK; } @@ -1416,7 +1430,9 @@ buffers: return ndr_pull_error(ndr, NDR_ERR_CONFORMANT_SIZE, "Bad conformant size %u should be %u", _conformant_size, r->count); } NDR_ALLOC_N_SIZE(ndr, r->set, _conformant_size, sizeof(r->set[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->set, sizeof(r->set[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_lsa_LUIDAttribute)); + } done: return NT_STATUS_OK; } @@ -1592,8 +1608,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->names, r->count, sizeof(r->names[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->names, sizeof(r->names[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_lsa_Name)); } + } done: return NT_STATUS_OK; } diff --git a/source4/librpc/ndr/ndr_misc.c b/source4/librpc/ndr/ndr_misc.c index 31f501e614..575f0d3a4d 100644 --- a/source4/librpc/ndr/ndr_misc.c +++ b/source4/librpc/ndr/ndr_misc.c @@ -90,14 +90,22 @@ NTSTATUS ndr_pull_dom_sid(struct ndr_pull *ndr, int ndr_flags, struct dom_sid *r NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint8(ndr, &r->sid_rev_num)); NDR_CHECK(ndr_pull_uint8(ndr, &r->num_auths)); + { NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->id_auth, 6)); + } NDR_ALLOC_N_SIZE(ndr, r->sub_auths, r->num_auths, sizeof(r->sub_auths[0])); + { NDR_CHECK(ndr_pull_array_uint32(ndr, NDR_SCALARS, r->sub_auths, r->num_auths)); + } ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; + { NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_BUFFERS, r->id_auth, 6)); + } + { NDR_CHECK(ndr_pull_array_uint32(ndr, NDR_BUFFERS, r->sub_auths, r->num_auths)); + } done: return NT_STATUS_OK; } @@ -127,11 +135,15 @@ NTSTATUS ndr_pull_security_acl(struct ndr_pull *ndr, int ndr_flags, struct secur NDR_CHECK(ndr_pull_uint16(ndr, &r->revision)); NDR_CHECK(ndr_pull_uint32(ndr, &r->num_aces)); NDR_ALLOC_N_SIZE(ndr, r->aces, r->num_aces, sizeof(r->aces[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS, (void **)r->aces, sizeof(r->aces[0]), r->num_aces, (ndr_pull_flags_fn_t)ndr_pull_security_ace)); + } ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; + { NDR_CHECK(ndr_pull_array(ndr, NDR_BUFFERS, (void **)r->aces, sizeof(r->aces[0]), r->num_aces, (ndr_pull_flags_fn_t)ndr_pull_security_ace)); + } done: return NT_STATUS_OK; } diff --git a/source4/librpc/ndr/ndr_samr.c b/source4/librpc/ndr/ndr_samr.c index 42ce47f8db..f2dcfb9124 100644 --- a/source4/librpc/ndr/ndr_samr.c +++ b/source4/librpc/ndr/ndr_samr.c @@ -347,14 +347,14 @@ NTSTATUS ndr_push_samr_UserInfo2(struct ndr_push *ndr, int ndr_flags, struct sam NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_samr_Name(ndr, NDR_SCALARS, &r->comment)); - NDR_CHECK(ndr_push_uint32(ndr, r->unknown1)); - NDR_CHECK(ndr_push_uint32(ndr, r->unknown2)); + NDR_CHECK(ndr_push_samr_Name(ndr, NDR_SCALARS, &r->unknown)); NDR_CHECK(ndr_push_uint16(ndr, r->country_code)); NDR_CHECK(ndr_push_uint16(ndr, r->code_page)); ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_push_samr_Name(ndr, NDR_BUFFERS, &r->comment)); + NDR_CHECK(ndr_push_samr_Name(ndr, NDR_BUFFERS, &r->unknown)); done: return NT_STATUS_OK; } @@ -1225,8 +1225,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->entries, r->count, sizeof(r->entries[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->entries, sizeof(r->entries[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_samr_SamEntry)); } + } done: return NT_STATUS_OK; } @@ -1705,8 +1707,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->ids, r->count, sizeof(r->ids[0])); + { NDR_CHECK(ndr_pull_array_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->ids, r->count)); } + } done: return NT_STATUS_OK; } @@ -1762,8 +1766,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->names, r->count, sizeof(r->names[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->names, sizeof(r->names[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_samr_Name)); } + } done: return NT_STATUS_OK; } @@ -2155,14 +2161,14 @@ NTSTATUS ndr_pull_samr_UserInfo2(struct ndr_pull *ndr, int ndr_flags, struct sam if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->comment)); - NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown1)); - NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown2)); + NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->unknown)); NDR_CHECK(ndr_pull_uint16(ndr, &r->country_code)); NDR_CHECK(ndr_pull_uint16(ndr, &r->code_page)); ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->comment)); + NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->unknown)); done: return NT_STATUS_OK; } @@ -2216,13 +2222,16 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->logon_hours, 1260, sizeof(r->logon_hours[0])); + { uint32 _offset, _length; NDR_CHECK(ndr_pull_uint32(ndr, &_offset)); NDR_CHECK(ndr_pull_uint32(ndr, &_length)); if (_offset != 0) return ndr_pull_error(ndr, NDR_ERR_OFFSET, "Bad array offset 0x%08x", _offset); if (_length > 1260 || _length != r->units_per_week/8) return ndr_pull_error(ndr, NDR_ERR_LENGTH, "Bad array length 0x%08x > size 0x%08x", _offset, 1260); + NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS|NDR_BUFFERS, r->logon_hours, _length)); } + } done: return NT_STATUS_OK; } @@ -2252,13 +2261,16 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->logon_hours, 1260, sizeof(r->logon_hours[0])); + { uint32 _offset, _length; NDR_CHECK(ndr_pull_uint32(ndr, &_offset)); NDR_CHECK(ndr_pull_uint32(ndr, &_length)); if (_offset != 0) return ndr_pull_error(ndr, NDR_ERR_OFFSET, "Bad array offset 0x%08x", _offset); if (_length > 1260 || _length != r->units_per_week/8) return ndr_pull_error(ndr, NDR_ERR_LENGTH, "Bad array length 0x%08x > size 0x%08x", _offset, 1260); + NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS|NDR_BUFFERS, r->logon_hours, _length)); } + } done: return NT_STATUS_OK; } @@ -2313,13 +2325,16 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->logon_hours, 1260, sizeof(r->logon_hours[0])); + { uint32 _offset, _length; NDR_CHECK(ndr_pull_uint32(ndr, &_offset)); NDR_CHECK(ndr_pull_uint32(ndr, &_length)); if (_offset != 0) return ndr_pull_error(ndr, NDR_ERR_OFFSET, "Bad array offset 0x%08x", _offset); if (_length > 1260 || _length != r->units_per_week/8) return ndr_pull_error(ndr, NDR_ERR_LENGTH, "Bad array length 0x%08x > size 0x%08x", _offset, 1260); + NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS|NDR_BUFFERS, r->logon_hours, _length)); } + } done: return NT_STATUS_OK; } @@ -2570,8 +2585,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->buffer, r->buf_count, sizeof(r->buffer[0])); + { NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS|NDR_BUFFERS, r->buffer, r->buf_count)); } + } if (r->logon_hours) { { uint32 _array_size; @@ -2581,13 +2598,16 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->logon_hours, 1260, sizeof(r->logon_hours[0])); + { uint32 _offset, _length; NDR_CHECK(ndr_pull_uint32(ndr, &_offset)); NDR_CHECK(ndr_pull_uint32(ndr, &_length)); if (_offset != 0) return ndr_pull_error(ndr, NDR_ERR_OFFSET, "Bad array offset 0x%08x", _offset); if (_length > 1260 || _length != r->units_per_week/8) return ndr_pull_error(ndr, NDR_ERR_LENGTH, "Bad array length 0x%08x > size 0x%08x", _offset, 1260); + NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS|NDR_BUFFERS, r->logon_hours, _length)); } + } done: return NT_STATUS_OK; } @@ -4314,8 +4334,7 @@ void ndr_print_samr_UserInfo2(struct ndr_print *ndr, const char *name, struct sa ndr_print_struct(ndr, name, "samr_UserInfo2"); ndr->depth++; ndr_print_samr_Name(ndr, "comment", &r->comment); - ndr_print_uint32(ndr, "unknown1", r->unknown1); - ndr_print_uint32(ndr, "unknown2", r->unknown2); + ndr_print_samr_Name(ndr, "unknown", &r->unknown); ndr_print_uint16(ndr, "country_code", r->country_code); ndr_print_uint16(ndr, "code_page", r->code_page); ndr->depth--; diff --git a/source4/librpc/ndr/ndr_samr.h b/source4/librpc/ndr/ndr_samr.h index 6b6f92d0d8..e148c9b90d 100644 --- a/source4/librpc/ndr/ndr_samr.h +++ b/source4/librpc/ndr/ndr_samr.h @@ -703,8 +703,7 @@ struct samr_UserInfo1 { struct samr_UserInfo2 { struct samr_Name comment; - uint32 unknown1; - uint32 unknown2; + struct samr_Name unknown; uint16 country_code; uint16 code_page; }; diff --git a/source4/librpc/ndr/ndr_spoolss.c b/source4/librpc/ndr/ndr_spoolss.c index b102a9292c..14ec78e8a1 100644 --- a/source4/librpc/ndr/ndr_spoolss.c +++ b/source4/librpc/ndr/ndr_spoolss.c @@ -1035,13 +1035,17 @@ NTSTATUS ndr_pull_spoolss_DeviceMode(struct ndr_pull *ndr, int ndr_flags, struct NDR_CHECK(ndr_pull_uint32(ndr, &r->panningwidth)); NDR_CHECK(ndr_pull_uint32(ndr, &r->panningheight)); NDR_ALLOC_N_SIZE(ndr, r->private, r->driverextra, sizeof(r->private[0])); + { NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->private, r->driverextra)); + } ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_nstring(ndr, NDR_BUFFERS, &r->devicename)); NDR_CHECK(ndr_pull_nstring(ndr, NDR_BUFFERS, &r->formname)); + { NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_BUFFERS, r->private, r->driverextra)); + } done: return NT_STATUS_OK; } diff --git a/source4/librpc/ndr/ndr_srvsvc.c b/source4/librpc/ndr/ndr_srvsvc.c index 4937e7e914..877ffea51d 100644 --- a/source4/librpc/ndr/ndr_srvsvc.c +++ b/source4/librpc/ndr/ndr_srvsvc.c @@ -1436,8 +1436,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->array, r->count, sizeof(r->array[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->array, sizeof(r->array[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_srvsvc_NetConn0)); } + } done: return NT_STATUS_OK; } @@ -1504,8 +1506,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->array, r->count, sizeof(r->array[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->array, sizeof(r->array[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_srvsvc_NetConn1)); } + } done: return NT_STATUS_OK; } @@ -1626,8 +1630,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->array, r->count, sizeof(r->array[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->array, sizeof(r->array[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_srvsvc_NetFile2)); } + } done: return NT_STATUS_OK; } @@ -1692,8 +1698,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->array, r->count, sizeof(r->array[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->array, sizeof(r->array[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_srvsvc_NetFile3)); } + } done: return NT_STATUS_OK; } @@ -1837,8 +1845,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->array, r->count, sizeof(r->array[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->array, sizeof(r->array[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_srvsvc_NetSess0)); } + } done: return NT_STATUS_OK; } @@ -1904,8 +1914,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->array, r->count, sizeof(r->array[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->array, sizeof(r->array[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_srvsvc_NetSess1)); } + } done: return NT_STATUS_OK; } @@ -1981,8 +1993,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->array, r->count, sizeof(r->array[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->array, sizeof(r->array[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_srvsvc_NetSess2)); } + } done: return NT_STATUS_OK; } @@ -2046,8 +2060,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->array, r->count, sizeof(r->array[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->array, sizeof(r->array[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_srvsvc_NetSess10)); } + } done: return NT_STATUS_OK; } @@ -2133,8 +2149,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->array, r->count, sizeof(r->array[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->array, sizeof(r->array[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_srvsvc_NetSess502)); } + } done: return NT_STATUS_OK; } @@ -2326,8 +2344,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->array, r->count, sizeof(r->array[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->array, sizeof(r->array[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_srvsvc_NetShare0)); } + } done: return NT_STATUS_OK; } @@ -2390,8 +2410,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->array, r->count, sizeof(r->array[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->array, sizeof(r->array[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_srvsvc_NetShare1)); } + } done: return NT_STATUS_OK; } @@ -2477,8 +2499,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->array, r->count, sizeof(r->array[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->array, sizeof(r->array[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_srvsvc_NetShare2)); } + } done: return NT_STATUS_OK; } @@ -2542,8 +2566,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->array, r->count, sizeof(r->array[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->array, sizeof(r->array[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_srvsvc_NetShare501)); } + } done: return NT_STATUS_OK; } @@ -2640,8 +2666,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->array, r->count, sizeof(r->array[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->array, sizeof(r->array[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_srvsvc_NetShare502)); } + } done: return NT_STATUS_OK; } @@ -2847,8 +2875,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->disk, r->size, sizeof(r->disk[0])); + { NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS|NDR_BUFFERS, r->disk, r->size)); } + } done: return NT_STATUS_OK; } @@ -2880,8 +2910,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->array, r->count, sizeof(r->array[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->array, sizeof(r->array[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_srvsvc_NetDisk0)); } + } done: return NT_STATUS_OK; } @@ -2967,8 +2999,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->addr, r->count, sizeof(r->addr[0])); + { NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS|NDR_BUFFERS, r->addr, r->count)); } + } done: return NT_STATUS_OK; } @@ -3042,8 +3076,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->array, r->count, sizeof(r->array[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->array, sizeof(r->array[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_srvsvc_NetTransport0)); } + } done: return NT_STATUS_OK; } @@ -3127,8 +3163,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->array, r->count, sizeof(r->array[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->array, sizeof(r->array[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_srvsvc_NetTransport1)); } + } done: return NT_STATUS_OK; } @@ -3171,8 +3209,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->array, r->count, sizeof(r->array[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->array, sizeof(r->array[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_srvsvc_NetTransport2)); } + } done: return NT_STATUS_OK; } diff --git a/source4/librpc/ndr/ndr_wkssvc.c b/source4/librpc/ndr/ndr_wkssvc.c index d6b1558d4c..d5f2fa4fda 100644 --- a/source4/librpc/ndr/ndr_wkssvc.c +++ b/source4/librpc/ndr/ndr_wkssvc.c @@ -634,8 +634,10 @@ buffers: } } NDR_ALLOC_N_SIZE(ndr, r->transports, r->count, sizeof(r->transports[0])); + { NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->transports, sizeof(r->transports[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_wkssvc_TransportInfo0)); } + } done: return NT_STATUS_OK; } diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c index f0604dbdff..349b78d9cd 100644 --- a/source4/torture/rpc/samr.c +++ b/source4/torture/rpc/samr.c @@ -30,9 +30,13 @@ static BOOL test_QueryUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, */ static void init_samr_Name(struct samr_Name *name, const char *s) { - name->name = s; name->name_len = strlen_m(s)*2; name->name_size = name->name_len; + if (name->name_len == 0) { + name->name = NULL; + } else { + name->name = s; + } } static BOOL test_Close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, @@ -77,25 +81,99 @@ static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; - struct samr_SetUserInfo r; + struct samr_SetUserInfo s; + struct samr_QueryUserInfo q; union samr_UserInfo u; BOOL ret = True; - r.in.handle = handle; - r.in.level = 13; - r.in.info = &u; + s.in.handle = handle; + s.in.info = &u; + q.in.handle = handle; + q.out.info = &u; + +#define TESTCALL(call, r) \ + status = dcerpc_samr_ ##call(p, mem_ctx, &r); \ + if (!NT_STATUS_IS_OK(status)) { \ + printf(#call " level %u failed - %s (line %d)\n", \ + r.in.level, nt_errstr(status), __LINE__); \ + ret = False; \ + break; \ + } + +#define STRING_EQUAL(s1, s2, field) \ + if ((s1 && !s2) || (s2 && !s1) || strcmp(s1, s2)) { \ + printf("Failed to set %s to '%s' (line %d)\n", \ + #field, s2, __LINE__); \ + ret = False; \ + break; \ + } - printf("Testing SetUserInfo level %u\n", r.in.level); +#define INT_EQUAL(i1, i2, field) \ + if (i1 != i2) { \ + printf("Failed to set %s to %u (line %d)\n", \ + #field, i2, __LINE__); \ + ret = False; \ + break; \ + } - init_samr_Name(&u.info13.description, "my description"); +#define TEST_USERINFO_NAME(lvl1, field1, lvl2, field2, value) do { \ + printf("field test %d/%s vs %d/%s\n", lvl1, #field1, lvl2, #field2); \ + q.in.level = lvl1; \ + TESTCALL(QueryUserInfo, q) \ + s.in.level = lvl1; \ + u = *q.out.info; \ + init_samr_Name(&u.info ## lvl1.field1, value); \ + TESTCALL(SetUserInfo, s) \ + init_samr_Name(&u.info ## lvl1.field1, ""); \ + TESTCALL(QueryUserInfo, q); \ + u = *q.out.info; \ + STRING_EQUAL(u.info ## lvl1.field1.name, value, field1); \ + q.in.level = lvl2; \ + TESTCALL(QueryUserInfo, q) \ + u = *q.out.info; \ + STRING_EQUAL(u.info ## lvl2.field2.name, value, field2); \ + } while (0) + +#define TEST_USERINFO_INT(lvl1, field1, lvl2, field2) do { \ + printf("field test %d/%s vs %d/%s\n", lvl1, #field1, lvl2, #field2); \ + q.in.level = lvl1; \ + TESTCALL(QueryUserInfo, q) \ + s.in.level = lvl1; \ + u = *q.out.info; \ + u.info ## lvl1.field1 = __LINE__; \ + TESTCALL(SetUserInfo, s) \ + u.info ## lvl1.field1 = 0; \ + TESTCALL(QueryUserInfo, q); \ + u = *q.out.info; \ + INT_EQUAL(u.info ## lvl1.field1, __LINE__, field1); \ + q.in.level = lvl2; \ + TESTCALL(QueryUserInfo, q) \ + u = *q.out.info; \ + INT_EQUAL(u.info ## lvl2.field2, __LINE__, field1); \ + } while (0) - status = dcerpc_samr_SetUserInfo(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("SetUserInfo level %u failed - %s\n", - r.in.level, nt_errstr(status)); - ret = False; - } + TEST_USERINFO_NAME(2, comment, 1, comment, "xx2-1 comment"); + TEST_USERINFO_NAME(2, comment, 21, comment, "xx2-21 comment"); + + TEST_USERINFO_NAME(6, full_name, 1, full_name, "xx6-1 full_name"); + TEST_USERINFO_NAME(6, full_name, 3, full_name, "xx6-3 full_name"); + TEST_USERINFO_NAME(6, full_name, 5, full_name, "xx6-5 full_name"); + TEST_USERINFO_NAME(6, full_name, 6, full_name, "xx6-6 full_name"); + TEST_USERINFO_NAME(6, full_name, 8, full_name, "xx6-8 full_name"); + TEST_USERINFO_NAME(6, full_name, 21, full_name, "xx6-21 full_name"); + TEST_USERINFO_NAME(8, full_name, 21, full_name, "xx7-21 full_name"); + + TEST_USERINFO_NAME(11, logon_script, 21, logon_script, "xx11-21 logon_script"); + TEST_USERINFO_NAME(12, profile, 21, profile, "xx12-21 profile"); + TEST_USERINFO_NAME(13, description, 21, description, "xx13-21 description"); + TEST_USERINFO_NAME(14, workstations, 21, workstations, "testworkstation"); + TEST_USERINFO_NAME(20, callback, 21, callback, "xx20-21 callback"); + + TEST_USERINFO_INT(2, country_code, 21, country_code); + TEST_USERINFO_INT(2, code_page, 21, code_page); + TEST_USERINFO_INT(4, logon_hours[3], 5, logon_hours[3]); + return ret; } |