Changeset 988 for vendor/current/librpc/tools/ndrdump.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/librpc/tools/ndrdump.c
r740 r988 24 24 #include "librpc/ndr/libndr.h" 25 25 #include "librpc/ndr/ndr_table.h" 26 #i f (_SAMBA_BUILD_ >= 4)26 #include "librpc/gen_ndr/ndr_dcerpc.h" 27 27 #include "lib/cmdline/popt_common.h" 28 28 #include "param/param.h" 29 #endif30 29 31 30 static const struct ndr_interface_call *find_function( … … 120 119 printf("%s: Unable to find DCE/RPC interface table for '%s': %s\n", plugin, pipe_name, dlerror()); 121 120 talloc_free(symbol); 121 dlclose(handle); 122 122 return NULL; 123 123 } … … 128 128 } 129 129 130 static void printf_cb(const char *buf, void *private_data)131 {132 printf("%s", buf);133 }134 135 130 static void ndrdump_data(uint8_t *d, uint32_t l, bool force) 136 131 { 137 dump_data_ cb(d, l, !force, printf_cb, NULL);132 dump_data_file(d, l, !force, stdout); 138 133 } 139 134 … … 150 145 uint64_t idx = 0; 151 146 while (true) { 147 void *saved_mem_ctx; 152 148 uint32_t *count; 153 149 void *c; … … 166 162 (unsigned long long)idx); 167 163 164 saved_mem_ctx = ndr_pull->current_mem_ctx; 165 ndr_pull->current_mem_ctx = c; 168 166 ndr_err = pipes->pipes[i].ndr_pull(ndr_pull, NDR_SCALARS, c); 167 ndr_pull->current_mem_ctx = saved_mem_ctx; 169 168 status = ndr_map_error2ntstatus(ndr_err); 170 169 171 170 printf("pull returned %s\n", nt_errstr(status)); 172 171 if (!NT_STATUS_IS_OK(status)) { 172 talloc_free(c); 173 173 return status; 174 174 } 175 175 pipes->pipes[i].ndr_print(ndr_print, n, c); 176 176 talloc_free(c); 177 177 if (*count == 0) { 178 178 break; … … 220 220 { NULL } 221 221 }; 222 struct ndr_interface_call_pipes *in_pipes = NULL; 223 struct ndr_interface_call_pipes *out_pipes = NULL; 222 const struct ndr_interface_call_pipes *in_pipes = NULL; 223 const struct ndr_interface_call_pipes *out_pipes = NULL; 224 uint32_t highest_ofs; 225 struct dcerpc_sec_verification_trailer *sec_vt = NULL; 224 226 225 227 ndr_table_init(); 226 228 227 229 /* Initialise samba stuff */ 228 load_case_tables();230 smb_init_locale(); 229 231 230 232 setlinebuf(stdout); … … 342 344 343 345 ndr_pull = ndr_pull_init_blob(&blob, mem_ctx); 346 if (ndr_pull == NULL) { 347 perror("ndr_pull_init_blob"); 348 exit(1); 349 } 344 350 ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC; 345 351 if (assume_ndr64) { … … 349 355 ndr_err = f->ndr_pull(ndr_pull, NDR_IN, st); 350 356 351 if (ndr_pull->offset != ndr_pull->data_size) { 352 printf("WARNING! %d unread bytes while parsing context file\n", ndr_pull->data_size - ndr_pull->offset); 357 if (ndr_pull->offset > ndr_pull->relative_highest_offset) { 358 highest_ofs = ndr_pull->offset; 359 } else { 360 highest_ofs = ndr_pull->relative_highest_offset; 361 } 362 363 if (highest_ofs != ndr_pull->data_size) { 364 printf("WARNING! %d unread bytes while parsing context file\n", ndr_pull->data_size - highest_ofs); 353 365 } 354 366 … … 378 390 379 391 ndr_pull = ndr_pull_init_blob(&blob, mem_ctx); 392 if (ndr_pull == NULL) { 393 perror("ndr_pull_init_blob"); 394 exit(1); 395 } 380 396 ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC; 381 397 if (assume_ndr64) { … … 386 402 ndr_print->print = ndr_print_printf_helper; 387 403 ndr_print->depth = 1; 404 405 ndr_err = ndr_pop_dcerpc_sec_verification_trailer(ndr_pull, mem_ctx, &sec_vt); 406 status = ndr_map_error2ntstatus(ndr_err); 407 if (!NT_STATUS_IS_OK(status)) { 408 printf("ndr_pop_dcerpc_sec_verification_trailer returned %s\n", 409 nt_errstr(status)); 410 } 411 412 if (sec_vt != NULL && sec_vt->count.count > 0) { 413 printf("SEC_VT: consumed %d bytes\n", 414 (int)(blob.length - ndr_pull->data_size)); 415 if (dumpdata) { 416 ndrdump_data(blob.data + ndr_pull->data_size, 417 blob.length - ndr_pull->data_size, 418 dumpdata); 419 } 420 ndr_print_dcerpc_sec_verification_trailer(ndr_print, "SEC_VT", sec_vt); 421 } 422 TALLOC_FREE(sec_vt); 388 423 389 424 if (out_pipes) { … … 400 435 printf("pull returned %s\n", nt_errstr(status)); 401 436 402 if (ndr_pull->offset != ndr_pull->data_size) { 403 printf("WARNING! %d unread bytes\n", ndr_pull->data_size - ndr_pull->offset); 404 ndrdump_data(ndr_pull->data+ndr_pull->offset, 405 ndr_pull->data_size - ndr_pull->offset, 437 if (ndr_pull->offset > ndr_pull->relative_highest_offset) { 438 highest_ofs = ndr_pull->offset; 439 } else { 440 highest_ofs = ndr_pull->relative_highest_offset; 441 } 442 443 if (highest_ofs != ndr_pull->data_size) { 444 printf("WARNING! %d unread bytes\n", ndr_pull->data_size - highest_ofs); 445 ndrdump_data(ndr_pull->data+highest_ofs, 446 ndr_pull->data_size - highest_ofs, 406 447 dumpdata); 407 448 } … … 454 495 455 496 ndr_v_pull = ndr_pull_init_blob(&v_blob, mem_ctx); 497 if (ndr_v_pull == NULL) { 498 perror("ndr_pull_init_blob"); 499 exit(1); 500 } 456 501 ndr_v_pull->flags |= LIBNDR_FLAG_REF_ALLOC; 457 502
Note:
See TracChangeset
for help on using the changeset viewer.