summaryrefslogtreecommitdiff
path: root/librpc/ndr
Commit message (Collapse)AuthorAgeFilesLines
* ndr_spoolss_buf: fix out of scope use of stack variable in ↵Stefan Metzmacher2019-03-261-2/+2
| | | | | | | | | | | | | | | NDR_SPOOLSS_PUSH_ENUM_OUT() BUG: https://bugzilla.samba.org/show_bug.cgi?id=13818 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Björn Jacke <bjacke@samba.org> Reviewed-by: Günther Deschner <gd@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> (cherry picked from commit 6da3664f8a11397fd3fb38e89c2432b8bf321e59)
* ndr_dns: fix pushing unknown resource recordsVolker Lendecke2018-01-041-1/+10
| | | | | | | | | When pulling for example an RRSIG record, we end up with length!=0 *and* unexpected.length != 0, but with an unknown rrec. We should be able to marshall what we retrieved from the wire. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* Use the rpc_parse debug class for PIDL genrated codeAndrew Bartlett2017-09-071-0/+3
| | | | | | | | | | This means that the default print binding string qualifier will now go via this debug class as will explicit calls to ndr_print_debug() and ndr_print_union_debug(). Calls to ndr_print_debugc() are not changed. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* lib: rpc: The registered interfaces are a lists of singletons that are never ↵Jeremy Allison2017-07-261-1/+11
| | | | | | | | | | | removed. Allocate them off the NULL context not the talloc_autofree_context(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=12932 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* librpc/ndr: add MSZIP compression for cabinet filesAurelien Aptel2017-07-192-12/+506
| | | | | | Signed-off-by: Aurelien Aptel <aaptel@suse.com> Reviewed-by: Guenther Deschner <gd@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* librpc/ndr: simplify cabinet file size calculationAurelien Aptel2017-07-191-50/+3
| | | | | | Signed-off-by: Aurelien Aptel <aaptel@suse.com> Reviewed-by: Guenther Deschner <gd@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* librpc/ndr: Use correct value for max compression sizeAndreas Schneider2017-07-191-2/+6
| | | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Guenther Deschner <gd@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* librpc/ndr: Use MAX_WBITS zlib define and change memLevel in MSZIP codeGünther Deschner2017-07-191-2/+2
| | | | | | | Guenther Signed-off-by: Günther Deschner <gd@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* librpc/ndr: remove unused ndr_cab_get_compression() functionAurelien Aptel2017-07-192-10/+0
| | | | | | Signed-off-by: Aurelien Aptel <aaptel@suse.com> Reviewed-by: Guenther Deschner <gd@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* librpc: use DATA_BLOB in CFDATA structureAurelien Aptel2017-07-191-1/+1
| | | | | | Signed-off-by: Aurelien Aptel <aaptel@suse.com> Reviewed-by: Guenther Deschner <gd@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* librpc/ndr: add helper functions to setup and free compression states.Aurelien Aptel2017-07-192-0/+155
| | | | | | Signed-off-by: Aurelien Aptel <aaptel@suse.com> Reviewed-by: Guenther Deschner <gd@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* librpc/ndr: add new MSZIP compression type for cabinet filesGünther Deschner2017-07-191-0/+1
| | | | | | | Guenther Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* librpc/ndr: add new ndr_compression_stateAurelien Aptel2017-07-192-0/+17
| | | | | | Signed-off-by: Aurelien Aptel <aaptel@suse.com> Reviewed-by: Guenther Deschner <gd@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* libndr/compression: pass down compressed length in ndr_pull_compression_startGünther Deschner2017-07-192-2/+4
| | | | | | | Guenther Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* librpc/ndr: remove trailing whitespace from compression file.Aurelien Aptel2017-07-191-7/+7
| | | | | | Signed-off-by: Aurelien Aptel <aaptel@suse.com> Reviewed-by: Guenther Deschner <gd@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* librpc:ndr_cab: Cast data pointer correctlyAndreas Schneider2017-07-191-2/+2
| | | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Guenther Deschner <gd@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* ndr_compression: use MAX_WBITS constantAurelien Aptel2017-07-191-1/+1
| | | | | | Signed-off-by: Aurelien Aptel <aaptel@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* librpc/ndr: add LIBNDR_FLAG_IS_SECRET handlingStefan Metzmacher2017-06-273-0/+77
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=12782 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* librpc/ndr: align the definition of LIBNDR_STRING_FLAGS with currently ↵Stefan Metzmacher2017-06-271-1/+13
| | | | | | | | | | | defined flags The range included the unused (1<<14) before. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12782 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* librpc:ndr: Set the length to 1 if we assign and empty stringAndreas Schneider2017-05-161-0/+1
| | | | | | | CID #1399648 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* ndr: Use resizing array instead of linked lists (breaking ABI)Douglas Bagnall2017-03-022-52/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ndr token code keeps a temporary store of tokens which are referred to a small number of times (often once) before being discarded. The access patterns are somewhat stack-like, with recently placed tokens being accessed most often. The old code kept these tokens in a linked list, which we replace with a self-resizing array. This keeps everything roughly the same in big-O terms, but makes it all faster in practice by vastly reducing the amount of tallocing and pointer-chasing. The peak memory use is strictly reduced. On a 64 bit machine each core token struct fits in 16 bytes (after padding) while the two pointers used by the DLIST add another 16 bytes, so the overall list allocation is the same as the peak 2n array allocation -- except in the list case it is dwarfed by the talloc and malloc metadata overhead. Before settling on the resized arrays, we tried red-black trees, which are bound to be better for large ndr structures. As it happens, we don't deal with large structures (the size of replication clumps is limited to 400 objects) and the asymptotic benefits of the trees are not realised in practice. With luck you should find graphs comparing the performance of these various techniques at: https://www.samba.org/~dbagnall/perf-tests/ndr-token/ This necessarily breaks the ABI because the linked list implementation was publicly exposed. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu Mar 2 08:38:22 CET 2017 on sn-devel-144
* ndr: fix whitespace in libndr.h, ndr.cDouglas Bagnall2017-03-022-37/+37
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* librpc/ndr: add ndr_push_charset_to_null and increase library version (abi ↵Günther Deschner2017-01-242-0/+17
| | | | | | | | | | | | | | change) We were crashing earlier when calculating the length of NULL strings in fixed size arrays (noticed while replying with an empty spoolss_CorePrinterDriver struct within the spoolss_GetCorePrinterDrivers call). Guenther Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* librpc: Use "all_zero" where appropriateVolker Lendecke2017-01-031-10/+2
| | | | | | | ... Saves a few bytes of footprint Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* CVE-2016-2123: Fix DNS vuln ZDI-CAN-3995Volker Lendecke2016-12-201-0/+9
| | | | | | | | Thanks to Trend Micro's Zero Day Initiative and Frederic Besler for finding this vulnerability with a PoC and a good analysis. Signed-off-by: Volker Lendecke <vl@samba.org> Bug: https://bugzilla.samba.org/show_bug.cgi?id=12409
* librpc/ndr/uuid.c: improve speed and accuracy of GUID string parsingDouglas Bagnall2016-12-141-21/+111
| | | | | | | | | | | | | | GUID_from_data_blob() was relying on sscanf to parse strings, which was slow and quite accepting of invalid GUIDs. Instead we directly read a fixed number of hex bytes for each field. This now passes the samba4.local.ndr.*.guid_from_string_invalid tests. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org> Autobuild-Date(master): Wed Dec 14 08:55:42 CET 2016 on sn-devel-144
* librpc: cab: Fix ndr_size_cab_file() to detect integer wrap.Jeremy Allison2016-12-011-5/+28
| | | | | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Dec 1 05:53:43 CET 2016 on sn-devel-144
* librpc: cab: Integer wrap protection for ndr_count_cfdata().Jeremy Allison2016-12-011-0/+4
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* librpc: Add ndr_cab_get_compression() for Cabinet compression evaluationGünther Deschner2016-11-242-0/+10
| | | | | | | Guenther Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* librpc: Add autogenerated file offset calculation for Cabinet filesGünther Deschner2016-11-241-0/+6
| | | | | | | Guenther Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* librpc: Add autogenerated total cabinet size for Cabinet filesGünther Deschner2016-11-241-0/+29
| | | | | | | Guenther Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* librpc: Add autogenerated checksum calculation for Cabinet filesGünther Deschner2016-11-242-0/+50
| | | | | | | Guenther Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* librpc: Introduce cab.idlGünther Deschner2016-11-242-0/+175
| | | | | | | | | | This allows processing of Windows Cabinet files (required for the MS-PAR print protocol implementation) Guenther Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* dcerpc.idl: set LIBNDR_FLAG_* flags based on DCERPC_PFC_FLAG_OBJECT_UUID and ↵Stefan Metzmacher2016-10-261-0/+82
| | | | | | | DCERPC_DREP_LE Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* spoolss: rename spoolss_EnumPrintProcDataTypes to ↵Günther Deschner2016-09-222-10/+10
| | | | | | | | | | | spoolss_EnumPrintProcessorDataTypes This change makes automatic mapping for PAR->RPRN opcodes easier. Guenther Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* librpc: Add ndr_push_struct_into_fixed_blob() and use it in GUID_to_ndr_blob()Andrew Bartlett2016-07-283-3/+51
| | | | | | | | This allows us to allocate only the correct size, not a default of 1024 bytes per push. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* krb5pac.idl: implement PAC_UPN_DNS_INFO correctStefan Metzmacher2016-07-201-0/+2
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Günther Deschner <gd@samba.org>
* krb5pac: fix push/pull of subcontexts in PAC_BUFFERStefan Metzmacher2016-07-201-10/+11
| | | | | | | | | We need to have two subcontexts to get the padding right, the outer subcontext uses NDR_ROUND(_ndr_size, 8), while the inner subcontext only uses _ndr_size. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Günther Deschner <gd@samba.org>
* krb5pac: no need for a noprint PAC_BUFFER.Günther Deschner2016-07-202-18/+27
| | | | | | | | | | | | | | | | | | | | | | | | Guenther @@ -1,6 +1,7 @@ _PUBLIC_ void ndr_print_PAC_BUFFER(struct ndr_print *ndr, const char *name, const struct PAC_BUFFER *r) { ndr_print_struct(ndr, name, "PAC_BUFFER"); + if (r == NULL) { ndr_print_null(ndr); return; } ndr->depth++; ndr_print_PAC_TYPE(ndr, "type", r->type); ndr_print_uint32(ndr, "_ndr_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?_ndr_size_PAC_INFO(r->info,r->type,0):r->_ndr_size); @@ -11,7 +12,7 @@ ndr_print_PAC_INFO(ndr, "info", r->info); } ndr->depth--; - ndr_print_uint32(ndr, "_pad", r->_pad); + ndr_print_uint32(ndr, "_pad", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0:r->_pad); ndr->depth--; } Signed-off-by: Günther Deschner <gd@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* drsblobs.idl: supplementalCredentialsSubBlob make it possible to parse ↵Stefan Metzmacher2016-07-201-4/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | strange blobs Windows omits the uint16 num_packages field when the packages array is empty. This happens if the UF_SMARTCARD_REQUIRED flag is set for an account. A user was created with a password and then userAccountControl was changed to UF_NORMAL_ACCOUNT|UF_SMARTCARD_REQUIRED. In that case I'm getting (as the whole supplementalCredentialsBlob): [0000] 00 00 00 00 62 00 00 00 00 00 00 00 20 00 20 00 ....b... .... . . [0010] 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 . . . . . . . . [0020] 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 . . . . . . . . [0030] 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 . . . . . . . . [0040] 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 . . . . . . . . [0050] 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 . . . . . . . . [0060] 20 00 20 00 20 00 20 00 20 00 20 00 50 00 30 . . . . . .P.0 I've also got cases (where I created an account with UF_NORMAL_ACCOUNT|UF_ACCOUNTDISABLE|UF_SMARTCARD_REQUIRED in the LDAP add) with the following strange blobs: One time: [0000] 00 00 00 00 00 00 00 00 00 00 00 00 00 and once: [0000] 00 00 00 00 00 00 00 00 00 00 00 00 53 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11441 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Günther Deschner <gd@samba.org>
* drsblobs.idl: mark supplementalCredentialsSubBlob as nopull,nopushStefan Metzmacher2016-07-201-0/+47
| | | | | | | | | | This commit moves the autogenerated ndr_{pull,push}_supplementalCredentialsSubBlob() function to the handwritten librpc/ndr/ndr_drsblobs.c BUG: https://bugzilla.samba.org/show_bug.cgi?id=11441 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Günther Deschner <gd@samba.org>
* typo: componemt => componentGarming Sam2016-07-051-1/+1
| | | | | Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* librpc: add decode_netlogon_samlogon_response_packet for mailslot debugging.Günther Deschner2016-07-011-11/+0
| | | | | | | | | | Guenther Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Jul 1 01:29:42 CEST 2016 on sn-devel-144
* librpc/ndr: add support for NDR_ALIGN* to ndr_push_short_relative_ptr2()Stefan Metzmacher2016-06-271-6/+36
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* librpc: Avoid talloc in GUID_from_data_blob()Andrew Bartlett2016-06-271-16/+8
| | | | | | | This is often found in inner loops in the dsdb code, because LDB DNs often contain a GUID string Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* librpc/dns: don't compress strings in TKEY and TSIG responsesRalph Boehme2016-06-161-0/+13
| | | | | | | | | | | | | | | Certain DNS clients fail TSIG record MAC validation if the TSIG record contains compressed strings. Windows DNS server behaviour seems to be to not send compressed names in TKEY and TSIG records. This patch ensures we conform to this behaviour. Bug: https://bugzilla.samba.org/show_bug.cgi?id=11520 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* librpc/ndr: add flag LIBNDR_FLAG_NO_COMPRESSIONRalph Boehme2016-06-162-23/+30
| | | | | | | | | | | | | | | | | | | This flag can be used to change marshalling behaviour with regard to compression. Example: DNS packets make use of so called DNS name compression which means that for identical strings in a DNS packet, the second string is replaced with a reference (an offset) to the first. Setting this flag requests to turns off the marshalling compression. This will be used in the next commit to prevent name compression in DNS TSIG records. Bug: https://bugzilla.samba.org/show_bug.cgi?id=11520 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* libndr: Add ndr_pull_struct_blob_all_noallocAndrew Bartlett2016-05-033-9/+44
| | | | | | | | | This allows us to remove talloc() calls from GUID_from_ndr_blob(). To do this the struct ndr_pull is placed on the stack, and filled in there. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* dns: remove double talloc for stringsGarming Sam2016-05-031-4/+0
| | | | | Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ndr: inline search for ndr_token_peek()Douglas Bagnall2016-03-221-8/+6
| | | | | | | | | This is often a hot path, particularly with complex structures like nt-acls. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>