1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-07 17:18:11 +03:00
samba-mirror/librpc/ndr/ndr_orpc.c

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

164 lines
4.8 KiB
C
Raw Normal View History

/*
Unix SMB/CIFS implementation.
routines for marshalling/unmarshalling DCOM string arrays
Copyright (C) Jelmer Vernooij 2004
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
r5490: The big (D)COM commit! :-) Contains most of the changes described in the DCOM paper in lorikeet. This is the result of 1.5 months work (mainly figuring out how things *really* work) at the end of 2004. In general: - Clearer distinction between COM and DCOM. DCOM is now merely the glue between DCE/RPC+ORPC and COM. COM can also work without DCOM now. This makes the code a lot clearer. - Clearer distinction between NDR and DCOM. Before, NDR had a couple of "if"s to cope with DCOM, which are now gone. - Use "real" arguments rather then structures for function arguments in COM, mainly because most of these calls are local so packing/unpacking data for every call is too much overhead (both speed- and code-wise) - Support several mechanisms to load class objects: - from memory (e.g. part of the current executable, registered at start-up) - from shared object files - remotely - Most things are now also named COM rather then DCOM because that's what it really is. After an object is created, it no longer matters whether it was created locally or remotely. There is a very simple example class that contains both a class factory and a class that implements the IStream interface. It can be tested (locally only, remotely is broken at the moment) by running the COM-SIMPLE smbtorture test. Still to-do: - Autogenerate parts of the class implementation code (using the coclass definitions in IDL) - Test server-side - Implement some of the common classes, add definitions for common interfaces. (This used to be commit 71fd3e5c3aac5f0002001ab29d2248e6c6842d6f)
2005-02-21 17:30:49 +03:00
#include "librpc/gen_ndr/ndr_orpc.h"
enum ndr_err_code ndr_pull_DUALSTRINGARRAY(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct DUALSTRINGARRAY *ar)
{
uint16_t num_entries, security_offset;
uint16_t towerid;
uint32_t towernum = 0, conformant_size;
if (!(ndr_flags & NDR_SCALARS)) {
return NDR_ERR_SUCCESS;
}
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &conformant_size));
NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &num_entries));
NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &security_offset));
ar->stringbindings = talloc_array(ndr, struct STRINGBINDING *, 1);
ar->stringbindings[0] = NULL;
do {
/* 'Peek' */
NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &towerid));
if (towerid > 0) {
ndr->offset -= 2;
ar->stringbindings = talloc_realloc(ndr, ar->stringbindings, struct STRINGBINDING *, towernum+2);
ar->stringbindings[towernum] = talloc(ndr, struct STRINGBINDING);
NDR_CHECK(ndr_pull_STRINGBINDING(ndr, ndr_flags, ar->stringbindings[towernum]));
towernum++;
}
} while (towerid != 0);
ar->stringbindings[towernum] = NULL;
towernum = 0;
ar->securitybindings = talloc_array(ndr, struct SECURITYBINDING *, 1);
ar->securitybindings[0] = NULL;
do {
/* 'Peek' */
NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &towerid));
if (towerid > 0) {
ndr->offset -= 2;
ar->securitybindings = talloc_realloc(ndr, ar->securitybindings, struct SECURITYBINDING *, towernum+2);
ar->securitybindings[towernum] = talloc(ndr, struct SECURITYBINDING);
NDR_CHECK(ndr_pull_SECURITYBINDING(ndr, ndr_flags, ar->securitybindings[towernum]));
towernum++;
}
} while (towerid != 0);
ar->securitybindings[towernum] = NULL;
return NDR_ERR_SUCCESS;
}
enum ndr_err_code ndr_push_DUALSTRINGARRAY(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct DUALSTRINGARRAY *ar)
{
return ndr_push_error(ndr, NDR_ERR_STRING, "ndr_push_DUALSTRINGARRAY not implemented");
}
/*
print a dom_sid
*/
void ndr_print_DUALSTRINGARRAY(struct ndr_print *ndr, const char *name, const struct DUALSTRINGARRAY *ar)
{
int i;
ndr->print(ndr, "%-25s: DUALSTRINGARRAY", name);
ndr->depth++;
ndr->print(ndr, "STRING BINDINGS");
ndr->depth++;
for (i=0;ar->stringbindings[i];i++) {
librpc/ndr: Fix fuzz CI on latest tumbleweed running samba-fuzz CI job on latest tumbleweed docker image results in; ../../librpc/ndr/ndr_orpc.c: In function ‘ndr_print_DUALSTRINGARRAY’: ../../librpc/ndr/ndr_orpc.c:97:49: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=] 97 | snprintf(idx, sizeof(idx), "[%d]", i); | ^ ../../librpc/ndr/ndr_orpc.c:97:17: note: ‘snprintf’ output between 4 and 14 bytes into a destination of size 13 97 | snprintf(idx, sizeof(idx), "[%d]", i); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../librpc/ndr/ndr_orpc.c:105:49: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=] 105 | snprintf(idx, sizeof(idx), "[%d]", i); | ^ ../../librpc/ndr/ndr_orpc.c:105:17: note: ‘snprintf’ output between 4 and 14 bytes into a destination of size 13 105 | snprintf(idx, sizeof(idx), "[%d]", i); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../librpc/ndr/ndr_orpc.c: In function ‘ndr_print_STRINGARRAY’: ../../librpc/ndr/ndr_orpc.c:159:49: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=] 159 | snprintf(idx, sizeof(idx), "[%d]", i); | ^ ../../librpc/ndr/ndr_orpc.c:159:17: note: ‘snprintf’ output between 4 and 14 bytes into a destination of size 13 159 | snprintf(idx, sizeof(idx), "[%d]", i); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org> Autobuild-Date(master): Tue Sep 10 01:22:28 UTC 2024 on atb-devel-224
2024-09-09 16:58:26 +03:00
char idx[14]; /* 2^32 has 10 digits */
snprintf(idx, sizeof(idx), "[%d]", i);
ndr_print_STRINGBINDING(ndr, idx, ar->stringbindings[i]);
}
ndr->depth--;
ndr->print(ndr, "SECURITY BINDINGS");
ndr->depth++;
for (i=0;ar->securitybindings[i];i++) {
librpc/ndr: Fix fuzz CI on latest tumbleweed running samba-fuzz CI job on latest tumbleweed docker image results in; ../../librpc/ndr/ndr_orpc.c: In function ‘ndr_print_DUALSTRINGARRAY’: ../../librpc/ndr/ndr_orpc.c:97:49: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=] 97 | snprintf(idx, sizeof(idx), "[%d]", i); | ^ ../../librpc/ndr/ndr_orpc.c:97:17: note: ‘snprintf’ output between 4 and 14 bytes into a destination of size 13 97 | snprintf(idx, sizeof(idx), "[%d]", i); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../librpc/ndr/ndr_orpc.c:105:49: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=] 105 | snprintf(idx, sizeof(idx), "[%d]", i); | ^ ../../librpc/ndr/ndr_orpc.c:105:17: note: ‘snprintf’ output between 4 and 14 bytes into a destination of size 13 105 | snprintf(idx, sizeof(idx), "[%d]", i); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../librpc/ndr/ndr_orpc.c: In function ‘ndr_print_STRINGARRAY’: ../../librpc/ndr/ndr_orpc.c:159:49: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=] 159 | snprintf(idx, sizeof(idx), "[%d]", i); | ^ ../../librpc/ndr/ndr_orpc.c:159:17: note: ‘snprintf’ output between 4 and 14 bytes into a destination of size 13 159 | snprintf(idx, sizeof(idx), "[%d]", i); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org> Autobuild-Date(master): Tue Sep 10 01:22:28 UTC 2024 on atb-devel-224
2024-09-09 16:58:26 +03:00
char idx[14]; /* 2^32 has 10 digits */
snprintf(idx, sizeof(idx), "[%d]", i);
ndr_print_SECURITYBINDING(ndr, idx, ar->securitybindings[i]);
}
ndr->depth--;
}
enum ndr_err_code ndr_pull_STRINGARRAY(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct STRINGARRAY *ar)
{
uint16_t towerid;
uint32_t towernum = 0;
uint16_t num_entries;
if (!(ndr_flags & NDR_SCALARS)) {
return NDR_ERR_SUCCESS;
}
NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &num_entries));
ar->stringbindings = talloc_array(ndr, struct STRINGBINDING *, 1);
ar->stringbindings[0] = NULL;
do {
/* 'Peek' */
NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &towerid));
if (towerid > 0) {
ndr->offset -= 2;
ar->stringbindings = talloc_realloc(ndr, ar->stringbindings, struct STRINGBINDING *, towernum+2);
ar->stringbindings[towernum] = talloc(ndr, struct STRINGBINDING);
NDR_CHECK(ndr_pull_STRINGBINDING(ndr, ndr_flags, ar->stringbindings[towernum]));
towernum++;
}
} while (towerid != 0);
ar->stringbindings[towernum] = NULL;
return NDR_ERR_SUCCESS;
}
enum ndr_err_code ndr_push_STRINGARRAY(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct STRINGARRAY *ar)
{
return ndr_push_error(ndr, NDR_ERR_STRING, "ndr_push_STRINGARRAY not implemented");
}
/*
print a dom_sid
*/
void ndr_print_STRINGARRAY(struct ndr_print *ndr, const char *name, const struct STRINGARRAY *ar)
{
int i;
ndr->print(ndr, "%-25s: STRINGARRAY", name);
ndr->depth++;
for (i=0;ar->stringbindings[i];i++) {
librpc/ndr: Fix fuzz CI on latest tumbleweed running samba-fuzz CI job on latest tumbleweed docker image results in; ../../librpc/ndr/ndr_orpc.c: In function ‘ndr_print_DUALSTRINGARRAY’: ../../librpc/ndr/ndr_orpc.c:97:49: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=] 97 | snprintf(idx, sizeof(idx), "[%d]", i); | ^ ../../librpc/ndr/ndr_orpc.c:97:17: note: ‘snprintf’ output between 4 and 14 bytes into a destination of size 13 97 | snprintf(idx, sizeof(idx), "[%d]", i); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../librpc/ndr/ndr_orpc.c:105:49: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=] 105 | snprintf(idx, sizeof(idx), "[%d]", i); | ^ ../../librpc/ndr/ndr_orpc.c:105:17: note: ‘snprintf’ output between 4 and 14 bytes into a destination of size 13 105 | snprintf(idx, sizeof(idx), "[%d]", i); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../librpc/ndr/ndr_orpc.c: In function ‘ndr_print_STRINGARRAY’: ../../librpc/ndr/ndr_orpc.c:159:49: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=] 159 | snprintf(idx, sizeof(idx), "[%d]", i); | ^ ../../librpc/ndr/ndr_orpc.c:159:17: note: ‘snprintf’ output between 4 and 14 bytes into a destination of size 13 159 | snprintf(idx, sizeof(idx), "[%d]", i); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org> Autobuild-Date(master): Tue Sep 10 01:22:28 UTC 2024 on atb-devel-224
2024-09-09 16:58:26 +03:00
char idx[14]; /* 2^32 has 10 digits */
snprintf(idx, sizeof(idx), "[%d]", i);
ndr_print_STRINGBINDING(ndr, idx, ar->stringbindings[i]);
}
ndr->depth--;
}