Changeset 988 for vendor/current/librpc/ndr
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/librpc/ndr
- Files:
-
- 14 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/librpc/ndr/libndr.h
r919 r988 27 27 28 28 #include <talloc.h> 29 #include <sys/time.h> 30 #if _SAMBA_BUILD_ == 4 31 #include "../lib/util/util.h" /* for discard_const */ 29 #include "../lib/util/memory.h" /* for discard_const */ 30 #include "../lib/util/byteorder.h" 31 #include "../lib/util/data_blob.h" 32 #include "../lib/util/time.h" 32 33 #include "../lib/util/charset/charset.h" 33 #endif34 34 35 35 /* … … 123 123 #define LIBNDR_FLAG_STR_CHARLEN (1<<11) 124 124 #define LIBNDR_FLAG_STR_UTF8 (1<<12) 125 #define LIBNDR_FLAG_STR_RAW8 (1<<13) 125 126 #define LIBNDR_STRING_FLAGS (0x7FFC) 126 127 … … 386 387 #include "librpc/gen_ndr/misc.h" 387 388 388 extern const struct ndr_syntax_id ndr_transfer_syntax ;389 extern const struct ndr_syntax_id ndr 64_transfer_syntax;390 extern const struct ndr_syntax_id n ull_ndr_syntax_id;389 extern const struct ndr_syntax_id ndr_transfer_syntax_ndr; 390 extern const struct ndr_syntax_id ndr_transfer_syntax_ndr64; 391 extern const struct ndr_syntax_id ndr_syntax_id_null; 391 392 392 393 struct ndr_interface_call_pipe { … … 434 435 }; 435 436 437 struct sockaddr_storage; 438 436 439 /********************************************************************* 437 440 Map an NT error code from a NDR error code. 438 441 *********************************************************************/ 439 442 NTSTATUS ndr_map_error2ntstatus(enum ndr_err_code ndr_err); 443 int ndr_map_error2errno(enum ndr_err_code ndr_err); 440 444 const char *ndr_map_error2string(enum ndr_err_code ndr_err); 441 445 #define ndr_errstr ndr_map_error2string … … 455 459 size_t ndr_size_dom_sid0(const struct dom_sid *sid, int flags); 456 460 void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid); 461 void ndr_print_sockaddr_storage(struct ndr_print *ndr, const char *name, const struct sockaddr_storage *ss); 457 462 bool ndr_syntax_id_equal(const struct ndr_syntax_id *i1, const struct ndr_syntax_id *i2); 458 463 char *ndr_syntax_id_to_string(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *id); … … 554 559 void ndr_print_ ## name(struct ndr_print *ndr, const char *var_name, type v); 555 560 561 #define NDR_SCALAR_PTR_PROTO(name, type) \ 562 enum ndr_err_code ndr_push_ ## name(struct ndr_push *ndr, int ndr_flags, const type *v); \ 563 enum ndr_err_code ndr_pull_ ## name(struct ndr_pull *ndr, int ndr_flags, type **v); \ 564 void ndr_print_ ## name(struct ndr_print *ndr, const char *var_name, const type *v); 565 556 566 #define NDR_BUFFER_PROTO(name, type) \ 557 567 enum ndr_err_code ndr_push_ ## name(struct ndr_push *ndr, int ndr_flags, const type *v); \ … … 578 588 NDR_SCALAR_PROTO(NTSTATUS, NTSTATUS) 579 589 NDR_SCALAR_PROTO(WERROR, WERROR) 590 NDR_SCALAR_PROTO(HRESULT, HRESULT) 580 591 NDR_SCALAR_PROTO(NTTIME, NTTIME) 581 592 NDR_SCALAR_PROTO(NTTIME_1sec, NTTIME) … … 590 601 enum ndr_err_code ndr_push_policy_handle(struct ndr_push *ndr, int ndr_flags, const struct policy_handle *r); 591 602 void ndr_print_policy_handle(struct ndr_print *ndr, const char *name, const struct policy_handle *r); 592 bool policy_handle_empty(const struct policy_handle *h);593 bool is_valid_policy_hnd(const struct policy_handle *hnd); 594 bool policy_handle_equal(const struct policy_handle *hnd1,603 bool ndr_policy_handle_empty(const struct policy_handle *h); 604 #define is_valid_policy_hnd(hnd) (!ndr_policy_handle_empty(hnd)) 605 bool ndr_policy_handle_equal(const struct policy_handle *hnd1, 595 606 const struct policy_handle *hnd2); 596 607 … … 643 654 NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid); 644 655 NTSTATUS GUID_from_string(const char *s, struct GUID *guid); 645 NTSTATUS NS_GUID_from_string(const char *s, struct GUID *guid);646 656 struct GUID GUID_zero(void); 647 657 bool GUID_all_zero(const struct GUID *u); … … 650 660 char *GUID_string2(TALLOC_CTX *mem_ctx, const struct GUID *guid); 651 661 char *GUID_hexstring(TALLOC_CTX *mem_ctx, const struct GUID *guid); 652 char *NS_GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid);653 662 struct GUID GUID_random(void); 663 664 /* Format is "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x" */ 665 /* 32 chars + 4 ' ' + \0 + 2 for adding {} */ 666 struct GUID_txt_buf { char buf[39]; }; 667 _PUBLIC_ char* GUID_buf_string(const struct GUID *guid, 668 struct GUID_txt_buf *dst); 654 669 655 670 _PUBLIC_ enum ndr_err_code ndr_pull_enum_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v); … … 664 679 _PUBLIC_ void ndr_print_bool(struct ndr_print *ndr, const char *name, const bool b); 665 680 681 _PUBLIC_ enum ndr_err_code ndr_push_timespec(struct ndr_push *ndr, 682 int ndr_flags, 683 const struct timespec *t); 684 _PUBLIC_ enum ndr_err_code ndr_pull_timespec(struct ndr_pull *ndr, 685 int ndr_flags, 686 struct timespec *t); 687 _PUBLIC_ void ndr_print_timespec(struct ndr_print *ndr, const char *name, 688 const struct timespec *t); 689 690 _PUBLIC_ enum ndr_err_code ndr_push_timeval(struct ndr_push *ndr, 691 int ndr_flags, 692 const struct timeval *t); 693 _PUBLIC_ enum ndr_err_code ndr_pull_timeval(struct ndr_pull *ndr, 694 int ndr_flags, 695 struct timeval *t); 696 _PUBLIC_ void ndr_print_timeval(struct ndr_print *ndr, const char *name, 697 const struct timeval *t); 698 699 700 666 701 #endif /* __LIBNDR_H__ */ -
vendor/current/librpc/ndr/ndr.c
r919 r988 1 /* 1 /* 2 2 Unix SMB/CIFS implementation. 3 3 … … 5 5 6 6 Copyright (C) Andrew Tridgell 2003 7 7 Copyright (C) Jelmer Vernooij 2005-2008 8 8 9 This program is free software; you can redistribute it and/or modify 9 10 it under the terms of the GNU General Public License as published by 10 11 the Free Software Foundation; either version 3 of the License, or 11 12 (at your option) any later version. 12 13 13 14 This program is distributed in the hope that it will be useful, 14 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 17 GNU General Public License for more details. 17 18 18 19 You should have received a copy of the GNU General Public License 19 20 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 30 31 #include "librpc/ndr/libndr.h" 31 32 #include "../lib/util/dlinklist.h" 32 #if _SAMBA_BUILD_ == 433 #include "param/param.h"34 #endif35 33 36 34 #define NDR_BASE_MARSHALL_SIZE 1024 37 35 38 36 /* this guid indicates NDR encoding in a protocol tower */ 39 const struct ndr_syntax_id ndr_transfer_syntax = {37 const struct ndr_syntax_id ndr_transfer_syntax_ndr = { 40 38 { 0x8a885d04, 0x1ceb, 0x11c9, {0x9f, 0xe8}, {0x08,0x00,0x2b,0x10,0x48,0x60} }, 41 39 2 42 40 }; 43 41 44 const struct ndr_syntax_id ndr 64_transfer_syntax= {42 const struct ndr_syntax_id ndr_transfer_syntax_ndr64 = { 45 43 { 0x71710533, 0xbeba, 0x4937, {0x83, 0x19}, {0xb5,0xdb,0xef,0x9c,0xcc,0x36} }, 46 44 1 47 45 }; 48 46 49 const struct ndr_syntax_id n ull_ndr_syntax_id= {47 const struct ndr_syntax_id ndr_syntax_id_null = { 50 48 { 0, 0, 0, { 0, 0 }, { 0, 0, 0, 0, 0, 0 } }, 51 49 0 … … 225 223 ndr->data = talloc_array(ndr, uint8_t, ndr->alloc_size); 226 224 if (!ndr->data) { 225 talloc_free(ndr); 227 226 return NULL; 228 227 } … … 638 637 NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &content_size)); 639 638 if (size_is >= 0 && size_is != content_size) { 640 return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PULL) size_is(%d) mismatch content_size %d", 641 (int)size_is, (int)content_size); 639 return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PULL) size_is(%d) (0x%04x) mismatch content_size %d (0x%04x)", 640 (int)size_is, (int)size_is, 641 (int)content_size, 642 (int)content_size); 642 643 } 643 644 r_content_size = content_size; … … 649 650 NDR_CHECK(ndr_pull_uint3264(ndr, NDR_SCALARS, &content_size)); 650 651 if (size_is >= 0 && size_is != content_size) { 651 return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PULL) size_is(%d) mismatch content_size %d", 652 (int)size_is, (int)content_size); 652 return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PULL) size_is(%d) (0x%08x) mismatch content_size %d (0x%08x)", 653 (int)size_is, (int)size_is, 654 (int)content_size, 655 (int)content_size); 653 656 } 654 657 r_content_size = content_size; -
vendor/current/librpc/ndr/ndr_backupkey.c
r740 r988 72 72 73 73 level = backupkeyguid_to_uint(r->in.guidActionAgent); 74 ndr_err = ndr_print_set_switch_value(ndr, &inblob, level); 75 if (unlikely(!NDR_ERR_CODE_IS_SUCCESS(ndr_err))) { \ 76 DEBUG(0,("ERROR: ndr_print_bkrp_BackupKey ndr_print_set_switch_value failed: %d\n", ndr_err)); 77 return; 78 } 74 79 blob.data = r->in.data_in; 75 80 blob.length = r->in.data_in_len; -
vendor/current/librpc/ndr/ndr_basic.c
r919 r988 1 /* 1 /* 2 2 Unix SMB/CIFS implementation. 3 3 … … 5 5 6 6 Copyright (C) Andrew Tridgell 2003 7 7 8 8 This program is free software; you can redistribute it and/or modify 9 9 it under the terms of the GNU General Public License as published by 10 10 the Free Software Foundation; either version 3 of the License, or 11 11 (at your option) any later version. 12 12 13 13 This program is distributed in the hope that it will be useful, 14 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 16 GNU General Public License for more details. 17 17 18 18 You should have received a copy of the GNU General Public License 19 19 along with this program. If not, see <http://www.gnu.org/licenses/>. 20 20 */ 21 21 22 #include " includes.h"22 #include "replace.h" 23 23 #include "system/network.h" 24 24 #include "librpc/ndr/libndr.h" 25 25 #include "lib/util/util_net.h" 26 #include "lib/util/debug.h" 27 #include "lib/util/util.h" 26 28 27 29 #define NDR_SVAL(ndr, ofs) (NDR_BE(ndr)?RSVAL(ndr->data,ofs):SVAL(ndr->data,ofs)) … … 32 34 #define NDR_SIVALS(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSIVALS(ndr->data,ofs,v); } else SIVALS(ndr->data,ofs,v); } while (0) 33 35 36 37 static void ndr_dump_data(struct ndr_print *ndr, const uint8_t *buf, int len); 34 38 35 39 /* … … 168 172 DEBUG(0,(__location__ ": non-zero upper 32 bits 0x%016llx\n", 169 173 (unsigned long long)v64)); 170 return NDR_ERR_NDR64; 174 return ndr_pull_error(ndr, NDR_ERR_NDR64, __location__ ": non-zero upper 32 bits 0x%016llx\n", 175 (unsigned long long)v64); 171 176 } 172 177 return err; … … 322 327 } 323 328 329 /* 330 pull a HRESULT 331 */ 332 _PUBLIC_ enum ndr_err_code ndr_pull_HRESULT(struct ndr_pull *ndr, int ndr_flags, HRESULT *status) 333 { 334 uint32_t v; 335 NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); 336 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); 337 *status = HRES_ERROR(v); 338 return NDR_ERR_SUCCESS; 339 } 324 340 325 341 /* … … 412 428 ndr->print(ndr, "%-25s: %s", name, win_errstr(r)); 413 429 } 430 431 /* 432 push a HRESULT 433 */ 434 _PUBLIC_ enum ndr_err_code ndr_push_HRESULT(struct ndr_push *ndr, int ndr_flags, HRESULT status) 435 { 436 return ndr_push_uint32(ndr, NDR_SCALARS, HRES_ERROR_V(status)); 437 } 438 439 _PUBLIC_ void ndr_print_HRESULT(struct ndr_print *ndr, const char *name, HRESULT r) 440 { 441 ndr->print(ndr, "%-25s: %s", name, hresult_errstr(r)); 442 } 443 414 444 415 445 /* … … 1003 1033 } 1004 1034 1005 _PUBLIC_ void ndr_print_enum(struct ndr_print *ndr, const char *name, const char *type, 1035 _PUBLIC_ void ndr_print_enum(struct ndr_print *ndr, const char *name, const char *type, 1006 1036 const char *val, uint32_t value) 1007 1037 { … … 1015 1045 _PUBLIC_ void ndr_print_bitmap_flag(struct ndr_print *ndr, size_t size, const char *flag_name, uint32_t flag, uint32_t value) 1016 1046 { 1047 if (flag == 0) { 1048 return; 1049 } 1050 1017 1051 /* this is an attempt to support multi-bit bitmap masks */ 1018 1052 value &= flag; … … 1021 1055 flag >>= 1; 1022 1056 value >>= 1; 1023 } 1057 } 1024 1058 if (flag == 1) { 1025 1059 ndr->print(ndr, " %d: %-25s", value, flag_name); … … 1159 1193 } 1160 1194 1161 _PUBLIC_ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, 1195 _PUBLIC_ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, 1162 1196 const uint8_t *data, uint32_t count) 1163 1197 { 1164 1198 int i; 1199 #define _ONELINE_LIMIT 32 1165 1200 1166 1201 if (data == NULL) { … … 1169 1204 } 1170 1205 1171 if (count <= 600&& (ndr->flags & LIBNDR_PRINT_ARRAY_HEX)) {1172 char s[ 1202];1206 if (count <= _ONELINE_LIMIT && (ndr->flags & LIBNDR_PRINT_ARRAY_HEX)) { 1207 char s[(_ONELINE_LIMIT + 1) * 2]; 1173 1208 for (i=0;i<count;i++) { 1174 1209 snprintf(&s[i*2], 3, "%02x", data[i]); … … 1180 1215 1181 1216 ndr->print(ndr, "%s: ARRAY(%d)", name, count); 1217 if (count > _ONELINE_LIMIT && (ndr->flags & LIBNDR_PRINT_ARRAY_HEX)) { 1218 ndr_dump_data(ndr, data, count); 1219 return; 1220 } 1221 1182 1222 ndr->depth++; 1183 1223 for (i=0;i<count;i++) { … … 1188 1228 } 1189 1229 } 1190 ndr->depth--; 1191 } 1192 1193 static void ndr_print_asc(struct ndr_print *ndr, const uint8_t *buf, int len) 1194 { 1195 int i; 1196 for (i=0;i<len;i++) 1197 ndr->print(ndr, "%c", isprint(buf[i])?buf[i]:'.'); 1230 ndr->depth--; 1231 #undef _ONELINE_LIMIT 1232 } 1233 1234 static void ndr_print_dump_data_cb(const char *buf, void *private_data) 1235 { 1236 struct ndr_print *ndr = (struct ndr_print *)private_data; 1237 1238 ndr->print(ndr, "%s", buf); 1198 1239 } 1199 1240 … … 1203 1244 static void ndr_dump_data(struct ndr_print *ndr, const uint8_t *buf, int len) 1204 1245 { 1205 int i=0;1206 1207 1246 ndr->no_newline = true; 1208 1209 for (i=0;i<len;) { 1210 if (i%16 == 0 && i<len) { 1211 ndr->print(ndr, "[%04X] ",i); 1212 } 1213 1214 ndr->print(ndr, "%02X ",(int)buf[i]); 1215 i++; 1216 if (i%8 == 0) ndr->print(ndr," "); 1217 if (i%16 == 0) { 1218 ndr_print_asc(ndr,&buf[i-16],8); ndr->print(ndr," "); 1219 ndr_print_asc(ndr,&buf[i-8],8); ndr->print(ndr, "\n"); 1220 } 1221 } 1222 1223 if (i%16) { 1224 int n; 1225 n = 16 - (i%16); 1226 ndr->print(ndr, " "); 1227 if (n>8) ndr->print(ndr," "); 1228 while (n--) ndr->print(ndr," "); 1229 n = MIN(8,i%16); 1230 ndr_print_asc(ndr,&buf[i-(i%16)],n); ndr->print(ndr, " "); 1231 n = (i%16) - n; 1232 if (n>0) ndr_print_asc(ndr,&buf[i-n],n); 1233 ndr->print(ndr,"\n"); 1234 } 1235 1247 dump_data_cb(buf, len, true, ndr_print_dump_data_cb, ndr); 1236 1248 ndr->no_newline = false; 1237 1249 } … … 1254 1266 * 2) When called with the LIBNDR_FLAG_REMAINING flag, push the byte array to 1255 1267 * the ndr buffer. 1256 * 3) Otherwise, push a uint32 length _and_ a corresponding byte array to the1268 * 3) Otherwise, push a uint3264 length _and_ a corresponding byte array to the 1257 1269 * ndr buffer. 1258 1270 */ … … 1272 1284 data_blob_clear(&blob); 1273 1285 } else { 1274 NDR_CHECK(ndr_push_uint32 (ndr, NDR_SCALARS, blob.length));1286 NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, blob.length)); 1275 1287 } 1276 1288 NDR_CHECK(ndr_push_bytes(ndr, blob.data, blob.length)); … … 1285 1297 * 2) When called with the LIBNDR_FLAG_REMAINING flag, pull all remaining bytes 1286 1298 * from the ndr buffer. 1287 * 3) Otherwise, pull a uint32 length _and_ a corresponding byte array from the1299 * 3) Otherwise, pull a uint3264 length _and_ a corresponding byte array from the 1288 1300 * ndr buffer. 1289 1301 */ … … 1306 1318 } 1307 1319 } else { 1308 NDR_CHECK(ndr_pull_uint32 (ndr, NDR_SCALARS, &length));1320 NDR_CHECK(ndr_pull_uint3264(ndr, NDR_SCALARS, &length)); 1309 1321 } 1310 1322 NDR_PULL_NEED_BYTES(ndr, length); … … 1349 1361 return NT_STATUS_INVALID_PARAMETER; 1350 1362 } 1363 1364 _PUBLIC_ int ndr_map_error2errno(enum ndr_err_code ndr_err) 1365 { 1366 switch (ndr_err) { 1367 case NDR_ERR_SUCCESS: 1368 return 0; 1369 case NDR_ERR_BUFSIZE: 1370 return ENOSPC; 1371 case NDR_ERR_TOKEN: 1372 return EINVAL; 1373 case NDR_ERR_ALLOC: 1374 return ENOMEM; 1375 case NDR_ERR_ARRAY_SIZE: 1376 return EMSGSIZE; 1377 case NDR_ERR_INVALID_POINTER: 1378 return EINVAL; 1379 case NDR_ERR_UNREAD_BYTES: 1380 return EOVERFLOW; 1381 default: 1382 break; 1383 } 1384 1385 /* we should map all error codes to different status codes */ 1386 return EINVAL; 1387 } 1388 1389 _PUBLIC_ enum ndr_err_code ndr_push_timespec(struct ndr_push *ndr, 1390 int ndr_flags, 1391 const struct timespec *t) 1392 { 1393 NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); 1394 NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, t->tv_sec)); 1395 NDR_CHECK(ndr_push_uint32(ndr, ndr_flags, t->tv_nsec)); 1396 return NDR_ERR_SUCCESS; 1397 } 1398 1399 _PUBLIC_ enum ndr_err_code ndr_pull_timespec(struct ndr_pull *ndr, 1400 int ndr_flags, 1401 struct timespec *t) 1402 { 1403 uint64_t secs; 1404 uint32_t nsecs; 1405 NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); 1406 NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, &secs)); 1407 NDR_CHECK(ndr_pull_uint32(ndr, ndr_flags, &nsecs)); 1408 t->tv_sec = secs; 1409 t->tv_nsec = nsecs; 1410 return NDR_ERR_SUCCESS; 1411 } 1412 1413 _PUBLIC_ void ndr_print_timespec(struct ndr_print *ndr, const char *name, 1414 const struct timespec *t) 1415 { 1416 ndr->print(ndr, "%-25s: %s.%ld", name, timestring(ndr, t->tv_sec), 1417 (long)t->tv_nsec); 1418 } 1419 1420 _PUBLIC_ enum ndr_err_code ndr_push_timeval(struct ndr_push *ndr, 1421 int ndr_flags, 1422 const struct timeval *t) 1423 { 1424 NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); 1425 NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, t->tv_sec)); 1426 NDR_CHECK(ndr_push_uint32(ndr, ndr_flags, t->tv_usec)); 1427 return NDR_ERR_SUCCESS; 1428 } 1429 1430 _PUBLIC_ enum ndr_err_code ndr_pull_timeval(struct ndr_pull *ndr, 1431 int ndr_flags, 1432 struct timeval *t) 1433 { 1434 uint64_t secs; 1435 uint32_t usecs; 1436 NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); 1437 NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, &secs)); 1438 NDR_CHECK(ndr_pull_uint32(ndr, ndr_flags, &usecs)); 1439 t->tv_sec = secs; 1440 t->tv_usec = usecs; 1441 return NDR_ERR_SUCCESS; 1442 } 1443 1444 _PUBLIC_ void ndr_print_timeval(struct ndr_print *ndr, const char *name, 1445 const struct timeval *t) 1446 { 1447 ndr->print(ndr, "%-25s: %s.%ld", name, timestring(ndr, t->tv_sec), 1448 (long)t->tv_usec); 1449 } -
vendor/current/librpc/ndr/ndr_dcerpc.c
r919 r988 23 23 #include "includes.h" 24 24 #include "librpc/gen_ndr/ndr_dcerpc.h" 25 26 25 #include "librpc/gen_ndr/ndr_misc.h" 27 #include "lib/util/bitmap.h" 26 27 /* 28 * This function was generated by pidl and 29 * has been extended by the (_available == 0) check. 30 * 31 * That's why we ignore the 80 char per line limit. 32 */ 33 enum ndr_err_code ndr_pull_dcerpc_bind_nak(struct ndr_pull *ndr, int ndr_flags, struct dcerpc_bind_nak *r) 34 { 35 uint32_t size_versions_0 = 0; 36 uint32_t cntr_versions_0; 37 TALLOC_CTX *_mem_save_versions_0 = NULL; 38 NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); 39 if (ndr_flags & NDR_SCALARS) { 40 uint32_t _available; 41 NDR_CHECK(ndr_pull_align(ndr, 4)); 42 NDR_CHECK(ndr_pull_dcerpc_bind_nak_reason(ndr, NDR_SCALARS, &r->reject_reason)); 43 _available = ndr->data_size - ndr->offset; 44 if (_available == 0) { 45 /* 46 * This works around a bug in older 47 * Samba (<= 4.1) releases. 48 * 49 * See bug #11327. 50 */ 51 r->num_versions = 0; 52 } else { 53 NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->num_versions)); 54 } 55 size_versions_0 = r->num_versions; 56 NDR_PULL_ALLOC_N(ndr, r->versions, size_versions_0); 57 _mem_save_versions_0 = NDR_PULL_GET_MEM_CTX(ndr); 58 NDR_PULL_SET_MEM_CTX(ndr, r->versions, 0); 59 for (cntr_versions_0 = 0; cntr_versions_0 < (size_versions_0); cntr_versions_0++) { 60 NDR_CHECK(ndr_pull_dcerpc_bind_nak_version(ndr, NDR_SCALARS, &r->versions[cntr_versions_0])); 61 } 62 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_versions_0, 0); 63 { 64 uint32_t _flags_save_DATA_BLOB = ndr->flags; 65 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); 66 NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->_pad)); 67 ndr->flags = _flags_save_DATA_BLOB; 68 } 69 NDR_CHECK(ndr_pull_trailer_align(ndr, 4)); 70 } 71 if (ndr_flags & NDR_BUFFERS) { 72 } 73 return NDR_ERR_SUCCESS; 74 } 28 75 29 76 const uint8_t DCERPC_SEC_VT_MAGIC[] = {0x8a,0xe3,0x13,0x71,0x02,0xf4,0x36,0x71}; -
vendor/current/librpc/ndr/ndr_dcerpc.h
r919 r988 24 24 struct ndr_pull *ndr, TALLOC_CTX *mem_ctx, 25 25 struct dcerpc_sec_verification_trailer **_r); 26 27 #ifndef NDR_DCERPC_REQUEST_OBJECT_PRESENT 28 #define NDR_DCERPC_REQUEST_OBJECT_PRESENT (ndr->flags & LIBNDR_FLAG_OBJECT_PRESENT) 29 #endif /* NDR_DCERPC_REQUEST_OBJECT_PRESENT */ -
vendor/current/librpc/ndr/ndr_dns.c
r740 r988 31 31 #include "librpc/gen_ndr/ndr_dns.h" 32 32 #include "librpc/gen_ndr/ndr_misc.h" 33 #include "librpc/gen_ndr/ndr_dnsp.h" 33 34 #include "system/locale.h" 34 35 #include "lib/util/util_net.h" … … 86 87 return ndr_pull_error(ndr, NDR_ERR_STRING, 87 88 "BAD DNS NAME component, " \ 88 "reserved leng htfield: 0x%02x",89 "reserved length field: 0x%02x", 89 90 (len &0xC)); 90 91 } 91 if (*offset + len + 2> ndr->data_size) {92 if (*offset + len + 1 > ndr->data_size) { 92 93 return ndr_pull_error(ndr, NDR_ERR_STRING, 93 94 "BAD DNS NAME component, "\ … … 169 170 uint32_t offset; 170 171 171 /* see if we have pushed the remain g string allready,172 /* see if we have pushed the remaining string already, 172 173 * if so we use a label pointer to this string 173 174 */ … … 229 230 */ 230 231 return ndr_push_bytes(ndr, (const uint8_t *)"", 1); 232 } 233 234 _PUBLIC_ enum ndr_err_code ndr_pull_dns_txt_record(struct ndr_pull *ndr, int ndr_flags, struct dns_txt_record *r) 235 { 236 NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); 237 if (ndr_flags & NDR_SCALARS) { 238 enum ndr_err_code ndr_err; 239 uint32_t data_size = ndr->data_size; 240 uint32_t record_size = 0; 241 ndr_err = ndr_token_retrieve(&ndr->array_size_list, r, 242 &record_size); 243 if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { 244 NDR_PULL_NEED_BYTES(ndr, record_size); 245 ndr->data_size = ndr->offset + record_size; 246 } 247 NDR_CHECK(ndr_pull_align(ndr, 1)); 248 NDR_CHECK(ndr_pull_dnsp_string_list(ndr, NDR_SCALARS, &r->txt)); 249 NDR_CHECK(ndr_pull_trailer_align(ndr, 1)); 250 ndr->data_size = data_size; 251 } 252 if (ndr_flags & NDR_BUFFERS) { 253 } 254 return NDR_ERR_SUCCESS; 231 255 } 232 256 … … 257 281 NDR_ERR_LENGTH, 258 282 "Invalid...Unexpected " \ 259 "blob leng htis too " \283 "blob length is too " \ 260 284 "large"); 261 285 } … … 263 287 if (r->unexpected.length > UINT16_MAX) { 264 288 return ndr_push_error(ndr, NDR_ERR_LENGTH, 265 "Unexpected blob leng ht"\289 "Unexpected blob length "\ 266 290 "is too large"); 267 291 } … … 303 327 _saved_offset1 = ndr->offset; 304 328 if (r->length > 0) { 329 NDR_CHECK(ndr_token_store(ndr, &ndr->array_size_list, 330 &r->rdata, 331 r->length)); 305 332 NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->rdata, 306 333 r->rr_type)); -
vendor/current/librpc/ndr/ndr_dnsp.c
r740 r988 49 49 ret = talloc_strdup(ndr->current_mem_ctx, ""); 50 50 if (!ret) { 51 return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp ");51 return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp_name"); 52 52 } 53 53 total_len = 1; … … 62 62 ret = talloc_realloc(ndr->current_mem_ctx, ret, char, newlen); 63 63 if (!ret) { 64 return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp ");64 return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp_name"); 65 65 } 66 66 NDR_CHECK(ndr_pull_bytes(ndr, (uint8_t *)&ret[total_len-1], sublen)); … … 73 73 NDR_CHECK(ndr_pull_uint8(ndr, ndr_flags, &termination)); 74 74 if (termination != 0) { 75 return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp - not NUL terminated");75 return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp_name - not NUL terminated"); 76 76 } 77 77 if (ndr->offset > raw_offset + len) { 78 return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp - overrun by %u bytes",78 return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp_name - overrun by %u bytes", 79 79 ndr->offset - (raw_offset + len)); 80 80 } … … 136 136 { 137 137 uint8_t len; 138 uint32_t total_len;139 138 char *ret; 140 139 … … 143 142 ret = talloc_strdup(ndr->current_mem_ctx, ""); 144 143 if (!ret) { 145 return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp"); 146 } 147 total_len = 1; 148 ret = talloc_zero_array(ndr->current_mem_ctx, char, len+1); 144 return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp_string"); 145 } 146 ret = talloc_zero_array(ndr->current_mem_ctx, char, len + 1); 149 147 if (!ret) { 150 return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp"); 151 } 152 NDR_CHECK(ndr_pull_bytes(ndr, (uint8_t *)&ret[total_len-1], len)); 153 total_len = len; 148 return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp_string"); 149 } 150 NDR_CHECK(ndr_pull_bytes(ndr, (uint8_t *)ret, len)); 154 151 155 152 (*string) = ret; … … 161 158 { 162 159 int total_len; 163 total_len = strlen(string) + 1;160 total_len = strlen(string); 164 161 if (total_len > 255) { 165 162 return ndr_push_error(ndr, NDR_ERR_BUFSIZE, … … 167 164 } 168 165 NDR_CHECK(ndr_push_uint8(ndr, ndr_flags, (uint8_t)total_len)); 169 NDR_CHECK(ndr_push_bytes(ndr, (const uint8_t *)string, total_len - 1)); 170 NDR_PUSH_ALIGN(ndr, 1); 171 172 return NDR_ERR_SUCCESS; 173 } 166 NDR_CHECK(ndr_push_bytes(ndr, (const uint8_t *)string, total_len)); 167 168 return NDR_ERR_SUCCESS; 169 } 170 171 /* 172 * print a dnsp_string_list 173 */ 174 _PUBLIC_ void ndr_print_dnsp_string_list(struct ndr_print *ndr, const char *name, 175 const struct dnsp_string_list *list) 176 { 177 uint32_t i; 178 179 ndr->no_newline = true; 180 for (i=0; i<ndr->depth; i++) { 181 ndr->print(ndr, " "); 182 } 183 ndr->print(ndr, "%-25s:", name); 184 for (i=0; i<list->count; i++) { 185 ndr->print(ndr, " \"%s\"", list->str[i]); 186 } 187 ndr->print(ndr, "\n"); 188 ndr->no_newline = false; 189 } 190 191 /* 192 * pull a dnsp_string_list 193 */ 194 _PUBLIC_ enum ndr_err_code ndr_pull_dnsp_string_list(struct ndr_pull *ndr, int ndr_flags, struct dnsp_string_list *list) 195 { 196 list->count = 0; 197 list->str = talloc_array(ndr->current_mem_ctx, const char *, 198 list->count); 199 if (! list->str) { 200 return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp_string_list"); 201 } 202 203 while (ndr->offset < ndr->data_size) { 204 list->str = talloc_realloc(ndr->current_mem_ctx, list->str, 205 const char *, list->count+1); 206 if (! list->str) { 207 return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp_string_list"); 208 } 209 NDR_CHECK(ndr_pull_dnsp_string(ndr, ndr_flags, &list->str[list->count])); 210 list->count++; 211 } 212 213 return NDR_ERR_SUCCESS; 214 } 215 216 enum ndr_err_code ndr_push_dnsp_string_list(struct ndr_push *ndr, int ndr_flags, const struct dnsp_string_list *list) 217 { 218 uint8_t i; 219 220 for (i=0; i<list->count; i++) { 221 NDR_CHECK(ndr_push_dnsp_string(ndr, ndr_flags, list->str[i])); 222 } 223 return NDR_ERR_SUCCESS; 224 } 225 226 enum ndr_err_code ndr_dnsp_string_list_copy(TALLOC_CTX *mem_ctx, 227 const struct dnsp_string_list *src, 228 struct dnsp_string_list *dst) 229 { 230 size_t i; 231 232 dst->count = 0; 233 dst->str = talloc_zero_array(mem_ctx, const char *, src->count); 234 if (dst->str == NULL) { 235 return NDR_ERR_ALLOC; 236 } 237 238 for (i = 0; i < src->count; i++) { 239 dst->str[i] = talloc_strdup(dst->str, src->str[i]); 240 if (dst->str[i] == NULL) { 241 TALLOC_FREE(dst->str); 242 return NDR_ERR_ALLOC; 243 } 244 } 245 246 dst->count = src->count; 247 return NDR_ERR_SUCCESS; 248 } -
vendor/current/librpc/ndr/ndr_dnsp.h
r740 r988 28 28 enum ndr_err_code ndr_pull_dnsp_string(struct ndr_pull *ndr, int ndr_flags, const char **string); 29 29 enum ndr_err_code ndr_push_dnsp_string(struct ndr_push *ndr, int ndr_flags, const char *string); 30 31 enum ndr_err_code ndr_dnsp_string_list_copy(TALLOC_CTX *mem_ctx, 32 const struct dnsp_string_list *src, 33 struct dnsp_string_list *dst); -
vendor/current/librpc/ndr/ndr_drsblobs.c
r740 r988 33 33 NDR_CHECK(ndr_push_AuthenticationInformation(ndr, NDR_SCALARS, &r->array[cntr_array_0])); 34 34 } 35 NDR_CHECK(ndr_push_ trailer_align(ndr, 4));35 NDR_CHECK(ndr_push_align(ndr, 4)); 36 36 } 37 37 if (ndr_flags & NDR_BUFFERS) { … … 52 52 r->count++; 53 53 } 54 NDR_CHECK(ndr_pull_ trailer_align(ndr, 4));54 NDR_CHECK(ndr_pull_align(ndr, 4)); 55 55 } 56 56 if (ndr_flags & NDR_BUFFERS) { … … 65 65 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count)); 66 66 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, (r->count > 0)?12:0)); 67 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, (r->count > 0)?12 + ndr_size_AuthenticationInformationArray(&r->current, ndr_flags):0));67 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, (r->count > 0)?12 + ndr_size_AuthenticationInformationArray(&r->current, 0):0)); 68 68 { 69 69 struct ndr_push *_ndr_current; 70 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_current, 0, ((r->count > 0)?12 + ndr_size_AuthenticationInformationArray(&r->current, ndr_flags):0) - ((r->count > 0)?12:0)));70 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_current, 0, ((r->count > 0)?12 + ndr_size_AuthenticationInformationArray(&r->current, 0):0) - ((r->count > 0)?12:0))); 71 71 NDR_CHECK(ndr_push_AuthenticationInformationArray(_ndr_current, NDR_SCALARS, &r->current)); 72 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_current, 0, ((r->count > 0)?12 + ndr_size_AuthenticationInformationArray(&r->current, ndr_flags):0) - ((r->count > 0)?12:0)));72 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_current, 0, ((r->count > 0)?12 + ndr_size_AuthenticationInformationArray(&r->current, 0):0) - ((r->count > 0)?12:0))); 73 73 } 74 74 { -
vendor/current/librpc/ndr/ndr_drsuapi.c
r740 r988 5 5 6 6 Copyright (C) Stefan (metze) Metzmacher 2005 7 Copyright (C) Matthieu Patou 2013 7 8 8 9 This program is free software; you can redistribute it and/or modify … … 102 103 const struct drsuapi_DsAttributeValue *r) 103 104 { 104 char *str; 105 void *p; 106 size_t converted_size = 0; 105 107 106 108 ndr_print_struct(ndr, name, "drsuapi_DsAttributeValue"); … … 110 112 r->blob->data, 111 113 r->blob->length, 112 (void **)&str, NULL, false)) {114 &p, &converted_size)) { 113 115 ndr_print_string(ndr, "string", "INVALID CONVERSION"); 114 116 } else { 117 char *str = (char *)p; 115 118 ndr_print_string(ndr, "string", str); 116 119 talloc_free(str); … … 405 408 } 406 409 } 410 411 enum ndr_err_code ndr_push_drsuapi_DsBindInfo(struct ndr_push *ndr, int ndr_flags, const union drsuapi_DsBindInfo *r) 412 { 413 uint32_t _flags_save = ndr->flags; 414 ndr->flags = ndr->flags & ~LIBNDR_FLAG_NDR64; 415 NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags); 416 if (ndr_flags & NDR_SCALARS) { 417 uint32_t level = ndr_push_get_switch_value(ndr, r); 418 NDR_CHECK(ndr_push_union_align(ndr, 4)); 419 switch (level) { 420 case 24: { 421 { 422 struct ndr_push *_ndr_info24; 423 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info24, 0, 24)); 424 NDR_CHECK(ndr_push_drsuapi_DsBindInfo24(_ndr_info24, NDR_SCALARS, &r->info24)); 425 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info24, 0, 24)); 426 } 427 break; } 428 429 case 28: { 430 { 431 struct ndr_push *_ndr_info28; 432 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info28, 0, 28)); 433 NDR_CHECK(ndr_push_drsuapi_DsBindInfo28(_ndr_info28, NDR_SCALARS, &r->info28)); 434 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info28, 0, 28)); 435 } 436 break; } 437 438 case 48: { 439 { 440 struct ndr_push *_ndr_info48; 441 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info48, 0, 48)); 442 NDR_CHECK(ndr_push_drsuapi_DsBindInfo48(_ndr_info48, NDR_SCALARS, &r->info48)); 443 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info48, 0, 48)); 444 } 445 break; } 446 447 case 52: { 448 { 449 struct ndr_push *_ndr_info52; 450 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info52, 0, 52)); 451 NDR_CHECK(ndr_push_drsuapi_DsBindInfo52(_ndr_info52, NDR_SCALARS, &r->info52)); 452 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info52, 0, 52)); 453 } 454 break; } 455 456 default: { 457 { 458 struct ndr_push *_ndr_Fallback; 459 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_Fallback, 0, level)); 460 NDR_CHECK(ndr_push_drsuapi_DsBindInfoFallBack(_ndr_Fallback, NDR_SCALARS, &r->Fallback)); 461 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_Fallback, 0, level)); 462 } 463 break; } 464 465 } 466 } 467 if (ndr_flags & NDR_BUFFERS) { 468 uint32_t level = ndr_push_get_switch_value(ndr, r); 469 switch (level) { 470 case 24: 471 break; 472 473 case 28: 474 break; 475 476 case 48: 477 break; 478 479 case 52: 480 break; 481 482 default: 483 break; 484 485 } 486 } 487 ndr->flags = _flags_save; 488 return NDR_ERR_SUCCESS; 489 } 490 491 enum ndr_err_code ndr_pull_drsuapi_DsBindInfo(struct ndr_pull *ndr, int ndr_flags, union drsuapi_DsBindInfo *r) 492 { 493 uint32_t level; 494 uint32_t _flags_save = ndr->flags; 495 ndr->flags = ndr->flags & ~LIBNDR_FLAG_NDR64; 496 level = ndr_pull_get_switch_value(ndr, r); 497 NDR_PULL_CHECK_FLAGS(ndr, ndr_flags); 498 if (ndr_flags & NDR_SCALARS) { 499 NDR_CHECK(ndr_pull_union_align(ndr, 4)); 500 switch (level) { 501 case 24: { 502 { 503 struct ndr_pull *_ndr_info24; 504 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_info24, 0, 24)); 505 NDR_CHECK(ndr_pull_drsuapi_DsBindInfo24(_ndr_info24, NDR_SCALARS, &r->info24)); 506 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_info24, 0, 24)); 507 } 508 break; } 509 510 case 28: { 511 { 512 struct ndr_pull *_ndr_info28; 513 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_info28, 0, 28)); 514 NDR_CHECK(ndr_pull_drsuapi_DsBindInfo28(_ndr_info28, NDR_SCALARS, &r->info28)); 515 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_info28, 0, 28)); 516 } 517 break; } 518 519 case 48: { 520 { 521 struct ndr_pull *_ndr_info48; 522 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_info48, 0, 48)); 523 NDR_CHECK(ndr_pull_drsuapi_DsBindInfo48(_ndr_info48, NDR_SCALARS, &r->info48)); 524 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_info48, 0, 48)); 525 } 526 break; } 527 528 case 52: { 529 { 530 struct ndr_pull *_ndr_info52; 531 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_info52, 0, 52)); 532 NDR_CHECK(ndr_pull_drsuapi_DsBindInfo52(_ndr_info52, NDR_SCALARS, &r->info52)); 533 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_info52, 0, 52)); 534 } 535 break; } 536 537 default: { 538 { 539 struct ndr_pull *_ndr_Fallback; 540 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_Fallback, 0, level)); 541 NDR_CHECK(ndr_pull_drsuapi_DsBindInfoFallBack(_ndr_Fallback, NDR_SCALARS, &r->Fallback)); 542 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_Fallback, 0, level)); 543 } 544 break; } 545 546 } 547 } 548 if (ndr_flags & NDR_BUFFERS) { 549 switch (level) { 550 case 24: 551 break; 552 553 case 28: 554 break; 555 556 case 48: 557 break; 558 559 case 52: 560 break; 561 562 default: 563 break; 564 565 } 566 } 567 ndr->flags = _flags_save; 568 return NDR_ERR_SUCCESS; 569 } 570 571 _PUBLIC_ void ndr_print_drsuapi_DsBindInfo(struct ndr_print *ndr, const char *name, const union drsuapi_DsBindInfo *r) 572 { 573 uint32_t level; 574 level = ndr_print_get_switch_value(ndr, r); 575 ndr_print_union(ndr, name, level, "drsuapi_DsBindInfo"); 576 switch (level) { 577 case 24: 578 ndr_print_drsuapi_DsBindInfo24(ndr, "info24", &r->info24); 579 break; 580 581 case 28: 582 ndr_print_drsuapi_DsBindInfo28(ndr, "info28", &r->info28); 583 break; 584 585 case 48: 586 ndr_print_drsuapi_DsBindInfo48(ndr, "info48", &r->info48); 587 break; 588 589 case 52: 590 ndr_print_drsuapi_DsBindInfo52(ndr, "info52", &r->info52); 591 break; 592 593 default: 594 ndr_print_drsuapi_DsBindInfoFallBack(ndr, "Fallback", &r->Fallback); 595 break; 596 597 } 598 } -
vendor/current/librpc/ndr/ndr_krb5pac.c
r740 r988 116 116 } 117 117 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); 118 if (ndr->offset > ndr->relative_highest_offset) { 119 ndr->relative_highest_offset = ndr->offset; 120 } 118 121 ndr->offset = _relative_save_offset; 119 122 } -
vendor/current/librpc/ndr/ndr_ntprinting.c
r860 r988 29 29 if (string_flags & LIBNDR_FLAG_STR_ASCII) { 30 30 flags |= LIBNDR_FLAG_STR_ASCII; 31 } else if (string_flags & LIBNDR_FLAG_STR_RAW8) { 32 flags |= LIBNDR_FLAG_STR_RAW8; 31 33 } else { 32 34 flags |= LIBNDR_FLAG_STR_UTF8; -
vendor/current/librpc/ndr/ndr_orpc.c
r414 r988 94 94 ndr->depth++; 95 95 for (i=0;ar->stringbindings[i];i++) { 96 char *idx = NULL; 97 asprintf(&idx, "[%d]", i); 98 if (idx) { 99 ndr_print_STRINGBINDING(ndr, idx, ar->stringbindings[i]); 100 free(idx); 101 } 96 char idx[13]; /* 2^32 has 10 digits */ 97 snprintf(idx, sizeof(idx), "[%d]", i); 98 ndr_print_STRINGBINDING(ndr, idx, ar->stringbindings[i]); 102 99 } 103 100 ndr->depth--; … … 105 102 ndr->depth++; 106 103 for (i=0;ar->securitybindings[i];i++) { 107 char *idx = NULL; 108 asprintf(&idx, "[%d]", i); 109 if (idx) { 110 ndr_print_SECURITYBINDING(ndr, idx, ar->securitybindings[i]); 111 free(idx); 112 } 104 char idx[13]; /* 2^32 has 10 digits */ 105 snprintf(idx, sizeof(idx), "[%d]", i); 106 ndr_print_SECURITYBINDING(ndr, idx, ar->securitybindings[i]); 113 107 } 114 108 ndr->depth--; … … 163 157 ndr->depth++; 164 158 for (i=0;ar->stringbindings[i];i++) { 165 char *idx = NULL; 166 asprintf(&idx, "[%d]", i); 167 if (idx) { 168 ndr_print_STRINGBINDING(ndr, idx, ar->stringbindings[i]); 169 free(idx); 170 } 159 char idx[13]; /* 2^32 has 10 digits */ 160 snprintf(idx, sizeof(idx), "[%d]", i); 161 ndr_print_STRINGBINDING(ndr, idx, ar->stringbindings[i]); 171 162 } 172 163 ndr->depth--; -
vendor/current/librpc/ndr/ndr_sec_helper.c
r740 r988 229 229 /* handle a w2k bug which send random data in the buffer */ 230 230 ZERO_STRUCTP(sid); 231 } else if (sid->num_auths == 0 && sid->sub_auths) {231 } else if (sid->num_auths == 0) { 232 232 ZERO_STRUCT(sid->sub_auths); 233 233 } … … 315 315 NDR_CHECK(ndr_push_int8(ndr, NDR_SCALARS, r->num_auths)); 316 316 NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->id_auth, 6)); 317 if (r->num_auths < 0 || r->num_auths > ARRAY_SIZE(r->sub_auths)) { 318 return ndr_push_error(ndr, NDR_ERR_RANGE, "value out of range"); 319 } 317 320 for (cntr_sub_auths_0 = 0; cntr_sub_auths_0 < r->num_auths; cntr_sub_auths_0++) { 318 321 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->sub_auths[cntr_sub_auths_0])); … … 329 332 NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->sid_rev_num)); 330 333 NDR_CHECK(ndr_pull_int8(ndr, NDR_SCALARS, &r->num_auths)); 331 if (r->num_auths < 0 || r->num_auths > 15) {334 if (r->num_auths < 0 || r->num_auths > ARRAY_SIZE(r->sub_auths)) { 332 335 return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range"); 333 336 } 334 337 NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->id_auth, 6)); 338 ZERO_STRUCT(r->sub_auths); 335 339 for (cntr_sub_auths_0 = 0; cntr_sub_auths_0 < r->num_auths; cntr_sub_auths_0++) { 336 340 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sub_auths[cntr_sub_auths_0])); -
vendor/current/librpc/ndr/ndr_spoolss_buf.c
r740 r988 26 26 #include "librpc/gen_ndr/ndr_spoolss.h" 27 27 #include "librpc/gen_ndr/ndr_security.h" 28 #if (_SAMBA_BUILD_ >= 4)29 #include "param/param.h"30 #endif31 28 32 29 #define NDR_SPOOLSS_PUSH_ENUM_IN(fn) do { \ -
vendor/current/librpc/ndr/ndr_string.c
r746 r988 31 31 uint32_t len1, ofs, len2; 32 32 uint16_t len3; 33 size_t conv erted_size;34 int chset = CH_UTF16;33 size_t conv_src_len = 0, converted_size; 34 int do_convert = 1, chset = CH_UTF16; 35 35 unsigned byte_mul = 2; 36 36 unsigned flags = ndr->flags; … … 55 55 byte_mul = 1; 56 56 flags &= ~LIBNDR_FLAG_STR_UTF8; 57 } 58 59 if (flags & LIBNDR_FLAG_STR_RAW8) { 60 do_convert = 0; 61 byte_mul = 1; 62 flags &= ~LIBNDR_FLAG_STR_RAW8; 57 63 } 58 64 … … 74 80 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &len2)); 75 81 if (len2 > len1) { 76 return ndr_pull_error(ndr, NDR_ERR_STRING, 77 "Bad string lengths len1=%u ofs=%u len2=%u\n", 82 return ndr_pull_error(ndr, NDR_ERR_STRING, 83 "Bad string lengths len1=%u ofs=%u len2=%u\n", 78 84 len1, ofs, len2); 79 } 80 NDR_PULL_NEED_BYTES(ndr, (len2 + c_len_term)*byte_mul); 81 if (len2 == 0) { 82 as = talloc_strdup(ndr->current_mem_ctx, ""); 83 } else { 84 if (!convert_string_talloc(ndr->current_mem_ctx, chset, 85 CH_UNIX, 86 ndr->data+ndr->offset, 87 (len2 + c_len_term)*byte_mul, 88 (void **)(void *)&as, 89 &converted_size, false)) 90 { 91 return ndr_pull_error(ndr, NDR_ERR_CHARCNV, 92 "Bad character conversion with flags 0x%x", flags); 93 } 94 } 95 NDR_CHECK(ndr_pull_advance(ndr, (len2 + c_len_term)*byte_mul)); 96 97 if (len1 != len2) { 85 } else if (len1 != len2) { 98 86 DEBUG(6,("len1[%u] != len2[%u] '%s'\n", len1, len2, as)); 99 87 } 100 101 /* this is a way of detecting if a string is sent with the wrong 102 termination */ 103 if (ndr->flags & LIBNDR_FLAG_STR_NOTERM) { 104 if (strlen(as) < (len2 + c_len_term)) { 105 DEBUG(6,("short string '%s'\n", as)); 106 } 107 } else { 108 if (strlen(as) == (len2 + c_len_term)) { 109 DEBUG(6,("long string '%s'\n", as)); 110 } 111 } 112 *s = as; 88 conv_src_len = len2 + c_len_term; 113 89 break; 114 90 … … 116 92 case LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: 117 93 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &len1)); 118 NDR_PULL_NEED_BYTES(ndr, (len1 + c_len_term)*byte_mul); 119 if (len1 == 0) { 120 as = talloc_strdup(ndr->current_mem_ctx, ""); 121 } else { 122 if (!convert_string_talloc(ndr->current_mem_ctx, chset, 123 CH_UNIX, 124 ndr->data+ndr->offset, 125 (len1 + c_len_term)*byte_mul, 126 (void **)(void *)&as, 127 &converted_size, false)) 128 { 129 return ndr_pull_error(ndr, NDR_ERR_CHARCNV, 130 "Bad character conversion with flags 0x%x", flags); 131 } 132 } 133 NDR_CHECK(ndr_pull_advance(ndr, (len1 + c_len_term)*byte_mul)); 134 135 /* this is a way of detecting if a string is sent with the wrong 136 termination */ 137 if (ndr->flags & LIBNDR_FLAG_STR_NOTERM) { 138 if (strlen(as) < (len1 + c_len_term)) { 139 DEBUG(6,("short string '%s'\n", as)); 140 } 141 } else { 142 if (strlen(as) == (len1 + c_len_term)) { 143 DEBUG(6,("long string '%s'\n", as)); 144 } 145 } 146 *s = as; 94 conv_src_len = len1 + c_len_term; 147 95 break; 148 96 … … 155 103 } 156 104 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &len1)); 157 NDR_PULL_NEED_BYTES(ndr, (len1 + c_len_term)*byte_mul); 158 if (len1 == 0) { 159 as = talloc_strdup(ndr->current_mem_ctx, ""); 160 } else { 161 if (!convert_string_talloc(ndr->current_mem_ctx, chset, 162 CH_UNIX, 163 ndr->data+ndr->offset, 164 (len1 + c_len_term)*byte_mul, 165 (void **)(void *)&as, 166 &converted_size, false)) 167 { 168 return ndr_pull_error(ndr, NDR_ERR_CHARCNV, 169 "Bad character conversion with flags 0x%x", flags); 170 } 171 } 172 NDR_CHECK(ndr_pull_advance(ndr, (len1 + c_len_term)*byte_mul)); 173 174 /* this is a way of detecting if a string is sent with the wrong 175 termination */ 176 if (ndr->flags & LIBNDR_FLAG_STR_NOTERM) { 177 if (strlen(as) < (len1 + c_len_term)) { 178 DEBUG(6,("short string '%s'\n", as)); 179 } 180 } else { 181 if (strlen(as) == (len1 + c_len_term)) { 182 DEBUG(6,("long string '%s'\n", as)); 183 } 184 } 185 *s = as; 186 break; 187 105 conv_src_len = len1 + c_len_term; 106 break; 188 107 189 108 case LIBNDR_FLAG_STR_SIZE2: 190 109 case LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM: 191 110 NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &len3)); 192 NDR_PULL_NEED_BYTES(ndr, (len3 + c_len_term)*byte_mul); 193 if (len3 == 0) { 194 as = talloc_strdup(ndr->current_mem_ctx, ""); 195 } else { 196 if (!convert_string_talloc(ndr->current_mem_ctx, chset, 197 CH_UNIX, 198 ndr->data+ndr->offset, 199 (len3 + c_len_term)*byte_mul, 200 (void **)(void *)&as, 201 &converted_size, false)) 202 { 203 return ndr_pull_error(ndr, NDR_ERR_CHARCNV, 204 "Bad character conversion with flags 0x%x", flags); 205 } 206 } 207 NDR_CHECK(ndr_pull_advance(ndr, (len3 + c_len_term)*byte_mul)); 208 209 /* this is a way of detecting if a string is sent with the wrong 210 termination */ 211 if (ndr->flags & LIBNDR_FLAG_STR_NOTERM) { 212 if (strlen(as) < (len3 + c_len_term)) { 213 DEBUG(6,("short string '%s'\n", as)); 214 } 215 } else { 216 if (strlen(as) == (len3 + c_len_term)) { 217 DEBUG(6,("long string '%s'\n", as)); 218 } 219 } 220 *s = as; 111 conv_src_len = len3 + c_len_term; 221 112 break; 222 113 223 114 case LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_BYTESIZE: 224 115 NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &len3)); 225 NDR_PULL_NEED_BYTES(ndr, len3); 226 if (len3 == 0) { 227 as = talloc_strdup(ndr->current_mem_ctx, ""); 228 } else { 229 if (!convert_string_talloc(ndr->current_mem_ctx, chset, 230 CH_UNIX, 231 ndr->data+ndr->offset, len3, 232 (void **)(void *)&as, 233 &converted_size, false)) 234 { 235 return ndr_pull_error(ndr, NDR_ERR_CHARCNV, 236 "Bad character conversion with flags 0x%x", flags); 237 } 238 } 239 NDR_CHECK(ndr_pull_advance(ndr, len3)); 240 *s = as; 116 conv_src_len = len3; 117 byte_mul = 1; /* the length is now absolute */ 241 118 break; 242 119 243 120 case LIBNDR_FLAG_STR_NULLTERM: 244 121 if (byte_mul == 1) { 245 len1= ascii_len_n((const char *)(ndr->data+ndr->offset), ndr->data_size - ndr->offset);122 conv_src_len = ascii_len_n((const char *)(ndr->data+ndr->offset), ndr->data_size - ndr->offset); 246 123 } else { 247 len1 = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset); 248 } 249 if (!convert_string_talloc(ndr->current_mem_ctx, chset, CH_UNIX, 250 ndr->data+ndr->offset, len1, 251 (void **)(void *)&as, 252 &converted_size, false)) 253 { 254 return ndr_pull_error(ndr, NDR_ERR_CHARCNV, 255 "Bad character conversion with flags 0x%x", flags); 256 } 257 NDR_CHECK(ndr_pull_advance(ndr, len1)); 258 *s = as; 124 conv_src_len = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset); 125 } 126 byte_mul = 1; /* the length is now absolute */ 259 127 break; 260 128 … … 264 132 ndr->flags & LIBNDR_STRING_FLAGS); 265 133 } 266 267 len1 = ndr->data_size - ndr->offset; 268 269 NDR_PULL_NEED_BYTES(ndr, len1); 270 if (len1 == 0) { 271 as = talloc_strdup(ndr->current_mem_ctx, ""); 272 } else { 273 if (!convert_string_talloc(ndr->current_mem_ctx, chset, 274 CH_UNIX, 275 ndr->data+ndr->offset, len1, 276 (void **)(void *)&as, 277 &converted_size, false)) 278 { 279 return ndr_pull_error(ndr, NDR_ERR_CHARCNV, 280 "Bad character conversion with flags 0x%x", flags); 281 } 282 } 283 NDR_CHECK(ndr_pull_advance(ndr, len1)); 284 285 *s = as; 134 conv_src_len = ndr->data_size - ndr->offset; 135 byte_mul = 1; /* the length is now absolute */ 286 136 break; 287 137 … … 290 140 ndr->flags & LIBNDR_STRING_FLAGS); 291 141 } 142 143 NDR_PULL_NEED_BYTES(ndr, conv_src_len * byte_mul); 144 if (conv_src_len == 0) { 145 as = talloc_strdup(ndr->current_mem_ctx, ""); 146 converted_size = 0; 147 } else { 148 if (!do_convert) { 149 as = talloc_strndup(ndr->current_mem_ctx, 150 (char *)ndr->data + ndr->offset, 151 conv_src_len); 152 if (!as) { 153 return ndr_pull_error(ndr, NDR_ERR_ALLOC, 154 "Failed to talloc_strndup() in RAW8 ndr_string_pull()"); 155 } 156 converted_size = MIN(strlen(as)+1, conv_src_len); 157 } else if (!convert_string_talloc(ndr->current_mem_ctx, chset, 158 CH_UNIX, ndr->data + ndr->offset, 159 conv_src_len * byte_mul, 160 (void **)(void *)&as, 161 &converted_size)) { 162 return ndr_pull_error(ndr, NDR_ERR_CHARCNV, 163 "Bad character conversion with flags 0x%x", flags); 164 } 165 } 166 167 /* this is a way of detecting if a string is sent with the wrong 168 termination */ 169 if (ndr->flags & LIBNDR_FLAG_STR_NOTERM) { 170 if (as && converted_size > 0 && as[converted_size-1] == '\0') { 171 DEBUG(6,("short string '%s', sent with NULL termination despite NOTERM flag in IDL\n", as)); 172 } 173 } else { 174 if (as && converted_size > 0 && as[converted_size-1] != '\0') { 175 DEBUG(6,("long string '%s', send without NULL termination (which was expected)\n", as)); 176 } 177 } 178 179 NDR_CHECK(ndr_pull_advance(ndr, conv_src_len * byte_mul)); 180 *s = as; 292 181 293 182 return NDR_ERR_SUCCESS; … … 302 191 ssize_t s_len, c_len; 303 192 size_t d_len; 304 int chset = CH_UTF16;193 int do_convert = 1, chset = CH_UTF16; 305 194 unsigned flags = ndr->flags; 306 195 unsigned byte_mul = 2; … … 329 218 } 330 219 220 if (flags & LIBNDR_FLAG_STR_RAW8) { 221 do_convert = 0; 222 byte_mul = 1; 223 flags &= ~LIBNDR_FLAG_STR_RAW8; 224 } 225 331 226 flags &= ~LIBNDR_FLAG_STR_CONFORMANT; 332 227 … … 334 229 s_len++; 335 230 } 336 if (!convert_string_talloc(ndr, CH_UNIX, chset, s, s_len, 337 (void **)(void *)&dest, &d_len, false)) 231 232 if (!do_convert) { 233 d_len = s_len; 234 dest = (uint8_t *)talloc_strndup(ndr, s, s_len); 235 } else if (!convert_string_talloc(ndr, CH_UNIX, chset, s, s_len, 236 (void **)(void *)&dest, &d_len)) 338 237 { 339 238 return ndr_push_error(ndr, NDR_ERR_CHARCNV, … … 404 303 unsigned c_len_term = 1; 405 304 406 c_len = s?strlen_m(s):0; 407 408 if (flags & (LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_UTF8)) { 305 if (flags & LIBNDR_FLAG_STR_RAW8) { 306 c_len = s?strlen(s):0; 307 } else { 308 c_len = s?strlen_m(s):0; 309 } 310 311 if (flags & (LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_RAW8|LIBNDR_FLAG_STR_UTF8)) { 409 312 byte_mul = 1; 410 313 } … … 612 515 uint32_t i; 613 516 size_t size = 0; 517 int rawbytes = 0; 518 519 if (flags & LIBNDR_FLAG_STR_RAW8) { 520 rawbytes = 1; 521 flags &= ~LIBNDR_FLAG_STR_RAW8; 522 } 614 523 615 524 switch (flags & LIBNDR_STRING_FLAGS) { 616 525 case LIBNDR_FLAG_STR_NULLTERM: 617 526 for (i = 0; i < count; i++) { 618 size += strlen_m_term(a[i]);527 size += rawbytes?strlen(a[i]) + 1:strlen_m_term(a[i]); 619 528 } 620 529 break; 621 530 case LIBNDR_FLAG_STR_NOTERM: 622 531 for (i = 0; i < count; i++) { 623 size += strlen_m(a[i]);532 size += rawbytes?strlen(a[i]):strlen_m(a[i]); 624 533 } 625 534 break; … … 651 560 652 561 save_offset = ndr->offset; 653 ndr_pull_advance(ndr, (count - 1) * element_size);562 NDR_CHECK(ndr_pull_advance(ndr, (count - 1) * element_size)); 654 563 NDR_PULL_NEED_BYTES(ndr, element_size); 655 564 … … 685 594 ndr->data+ndr->offset, length*byte_mul, 686 595 discard_const_p(void *, var), 687 &converted_size , false))596 &converted_size)) 688 597 { 689 598 return ndr_pull_error(ndr, NDR_ERR_CHARCNV, … … 712 621 713 622 str_len = ndr_string_length(ndr->data+ndr->offset, byte_mul); 714 str_len = MIN(str_len, length); /* overrun protection */ 715 623 str_len = MIN(str_len, length); /* overrun protection */ 716 624 if (!convert_string_talloc(ndr->current_mem_ctx, chset, CH_UNIX, 717 625 ndr->data+ndr->offset, str_len*byte_mul, 718 626 discard_const_p(void *, var), 719 &converted_size , false))627 &converted_size)) 720 628 { 721 629 return ndr_pull_error(ndr, NDR_ERR_CHARCNV, … … 729 637 _PUBLIC_ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags, const char *var, uint32_t length, uint8_t byte_mul, charset_t chset) 730 638 { 731 ssize_t re t, required;639 ssize_t required; 732 640 733 641 if (NDR_BE(ndr) && chset == CH_UTF16) { … … 740 648 741 649 if (required) { 742 ret = convert_string(CH_UNIX, chset, 650 size_t size = 0; 651 if (!convert_string(CH_UNIX, chset, 743 652 var, strlen(var), 744 ndr->data+ndr->offset, required, false); 745 if (ret == -1) { 746 return ndr_push_error(ndr, NDR_ERR_CHARCNV, 747 "Bad character conversion"); 653 ndr->data+ndr->offset, required, &size)) { 654 return ndr_push_error(ndr, NDR_ERR_CHARCNV, 655 "Bad character conversion"); 748 656 } 749 657 750 658 /* Make sure the remaining part of the string is filled with zeroes */ 751 if ( ret< required) {752 memset(ndr->data+ndr->offset+ ret, 0, required-ret);659 if (size < required) { 660 memset(ndr->data+ndr->offset+size, 0, required-size); 753 661 } 754 662 } … … 769 677 case CH_UTF8: 770 678 return strlen_m_ext_term((const char *)var, CH_UNIX, chset); 771 case CH_DISPLAY:772 679 case CH_DOS: 773 680 case CH_UNIX: -
vendor/current/librpc/ndr/ndr_table.c
r414 r988 74 74 { 75 75 const struct ndr_interface_list *l; 76 for (l=ndr_ interfaces;l;l=l->next){76 for (l=ndr_table_list();l;l=l->next){ 77 77 if (GUID_equal(&l->table->syntax_id.uuid, uuid) && 78 78 l->table->syntax_id.if_version == if_version) { … … 90 90 { 91 91 const struct ndr_interface_list *l; 92 for (l=ndr_ interfaces;l;l=l->next) {92 for (l=ndr_table_list();l;l=l->next) { 93 93 if (strcasecmp(l->table->name, name) == 0) { 94 return l->table; 95 } 96 } 97 return NULL; 98 } 99 100 /* 101 find a dcerpc interface by syntax 102 */ 103 const struct ndr_interface_table *ndr_table_by_syntax(const struct ndr_syntax_id *syntax) 104 { 105 const struct ndr_interface_list *l; 106 for (l=ndr_table_list();l;l=l->next) { 107 if (ndr_syntax_id_equal(&l->table->syntax_id, syntax)) { 94 108 return l->table; 95 109 } … … 104 118 { 105 119 const struct ndr_interface_list *l; 106 for (l=ndr_ interfaces;l;l=l->next) {120 for (l=ndr_table_list();l;l=l->next) { 107 121 if (GUID_equal(&l->table->syntax_id.uuid, uuid)) { 108 122 return l->table; … … 117 131 const struct ndr_interface_list *ndr_table_list(void) 118 132 { 133 ndr_table_init(); 119 134 return ndr_interfaces; 120 135 } -
vendor/current/librpc/ndr/ndr_table.h
r740 r988 28 28 int ndr_interface_num_calls(const struct GUID *uuid, uint32_t if_version); 29 29 const struct ndr_interface_table *ndr_table_by_name(const char *name); 30 const struct ndr_interface_table *ndr_table_by_syntax(const struct ndr_syntax_id *syntax); 30 31 const struct ndr_interface_table *ndr_table_by_uuid(const struct GUID *uuid); 31 32 const struct ndr_interface_list *ndr_table_list(void); -
vendor/current/librpc/ndr/ndr_wmi.c
r740 r988 24 24 #include "librpc/gen_ndr/ndr_dcom.h" 25 25 #include "librpc/gen_ndr/ndr_wmi.h" 26 #include "librpc/ndr/ndr_wmi.h" 26 27 27 28 // Just for debugging -
vendor/current/librpc/ndr/uuid.c
r740 r988 158 158 159 159 /** 160 build a GUID from a string161 */162 _PUBLIC_ NTSTATUS NS_GUID_from_string(const char *s, struct GUID *guid)163 {164 NTSTATUS status = NT_STATUS_INVALID_PARAMETER;165 uint32_t time_low;166 uint32_t time_mid, time_hi_and_version;167 uint32_t clock_seq[2];168 uint32_t node[6];169 int i;170 171 if (s == NULL) {172 return NT_STATUS_INVALID_PARAMETER;173 }174 175 if (11 == sscanf(s, "%08x-%04x%04x-%02x%02x%02x%02x-%02x%02x%02x%02x",176 &time_low, &time_mid, &time_hi_and_version,177 &clock_seq[0], &clock_seq[1],178 &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) {179 status = NT_STATUS_OK;180 }181 182 if (!NT_STATUS_IS_OK(status)) {183 return status;184 }185 186 guid->time_low = time_low;187 guid->time_mid = time_mid;188 guid->time_hi_and_version = time_hi_and_version;189 guid->clock_seq[0] = clock_seq[0];190 guid->clock_seq[1] = clock_seq[1];191 for (i=0;i<6;i++) {192 guid->node[i] = node[i];193 }194 195 return NT_STATUS_OK;196 }197 198 /**199 160 * generate a random GUID 200 161 */ … … 237 198 _PUBLIC_ bool GUID_equal(const struct GUID *u1, const struct GUID *u2) 238 199 { 239 if (u1->time_low != u2->time_low || 240 u1->time_mid != u2->time_mid || 241 u1->time_hi_and_version != u2->time_hi_and_version || 242 u1->clock_seq[0] != u2->clock_seq[0] || 243 u1->clock_seq[1] != u2->clock_seq[1] || 244 memcmp(u1->node, u2->node, 6) != 0) { 245 return false; 246 } 247 return true; 200 return (GUID_compare(u1, u2) == 0); 248 201 } 249 202 … … 278 231 _PUBLIC_ char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) 279 232 { 280 return talloc_asprintf(mem_ctx, 281 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", 282 guid->time_low, guid->time_mid, 283 guid->time_hi_and_version, 284 guid->clock_seq[0], 285 guid->clock_seq[1], 286 guid->node[0], guid->node[1], 287 guid->node[2], guid->node[3], 288 guid->node[4], guid->node[5]); 233 struct GUID_txt_buf buf; 234 return talloc_strdup(mem_ctx, GUID_buf_string(guid, &buf)); 235 } 236 237 /** 238 * Does the same without allocating memory, using the structure buffer. 239 * Useful for debug messages, so that you do not have to talloc_free the result 240 */ 241 _PUBLIC_ char* GUID_buf_string(const struct GUID *guid, 242 struct GUID_txt_buf *dst) 243 { 244 if (!guid) { 245 return NULL; 246 } 247 snprintf(dst->buf, sizeof(dst->buf), 248 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", 249 guid->time_low, guid->time_mid, 250 guid->time_hi_and_version, 251 guid->clock_seq[0], 252 guid->clock_seq[1], 253 guid->node[0], guid->node[1], 254 guid->node[2], guid->node[3], 255 guid->node[4], guid->node[5]); 256 return dst->buf; 289 257 } 290 258 … … 319 287 } 320 288 321 _PUBLIC_ char *NS_GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) 322 { 323 return talloc_asprintf(mem_ctx, 324 "%08x-%04x%04x-%02x%02x%02x%02x-%02x%02x%02x%02x", 325 guid->time_low, guid->time_mid, 326 guid->time_hi_and_version, 327 guid->clock_seq[0], 328 guid->clock_seq[1], 329 guid->node[0], guid->node[1], 330 guid->node[2], guid->node[3], 331 guid->node[4], guid->node[5]); 332 } 333 334 _PUBLIC_ bool policy_handle_empty(const struct policy_handle *h) 289 _PUBLIC_ bool ndr_policy_handle_empty(const struct policy_handle *h) 335 290 { 336 291 return (h->handle_type == 0 && GUID_all_zero(&h->uuid)); 337 292 } 338 293 339 _PUBLIC_ bool is_valid_policy_hnd(const struct policy_handle *hnd) 340 { 341 return !policy_handle_empty(hnd); 342 } 343 344 _PUBLIC_ bool policy_handle_equal(const struct policy_handle *hnd1, 294 _PUBLIC_ bool ndr_policy_handle_equal(const struct policy_handle *hnd1, 345 295 const struct policy_handle *hnd2) 346 296 {
Note:
See TracChangeset
for help on using the changeset viewer.