Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/librpc/tools/ndrdump.c

    r740 r988  
    2424#include "librpc/ndr/libndr.h"
    2525#include "librpc/ndr/ndr_table.h"
    26 #if (_SAMBA_BUILD_ >= 4)
     26#include "librpc/gen_ndr/ndr_dcerpc.h"
    2727#include "lib/cmdline/popt_common.h"
    2828#include "param/param.h"
    29 #endif
    3029
    3130static const struct ndr_interface_call *find_function(
     
    120119                printf("%s: Unable to find DCE/RPC interface table for '%s': %s\n", plugin, pipe_name, dlerror());
    121120                talloc_free(symbol);
     121                dlclose(handle);
    122122                return NULL;
    123123        }
     
    128128}
    129129
    130 static void printf_cb(const char *buf, void *private_data)
    131 {
    132         printf("%s", buf);
    133 }
    134 
    135130static void ndrdump_data(uint8_t *d, uint32_t l, bool force)
    136131{
    137         dump_data_cb(d, l, !force, printf_cb, NULL);
     132        dump_data_file(d, l, !force, stdout);
    138133}
    139134
     
    150145                uint64_t idx = 0;
    151146                while (true) {
     147                        void *saved_mem_ctx;
    152148                        uint32_t *count;
    153149                        void *c;
     
    166162                                        (unsigned long long)idx);
    167163
     164                        saved_mem_ctx = ndr_pull->current_mem_ctx;
     165                        ndr_pull->current_mem_ctx = c;
    168166                        ndr_err = pipes->pipes[i].ndr_pull(ndr_pull, NDR_SCALARS, c);
     167                        ndr_pull->current_mem_ctx = saved_mem_ctx;
    169168                        status = ndr_map_error2ntstatus(ndr_err);
    170169
    171170                        printf("pull returned %s\n", nt_errstr(status));
    172171                        if (!NT_STATUS_IS_OK(status)) {
     172                                talloc_free(c);
    173173                                return status;
    174174                        }
    175175                        pipes->pipes[i].ndr_print(ndr_print, n, c);
    176 
     176                        talloc_free(c);
    177177                        if (*count == 0) {
    178178                                break;
     
    220220                { NULL }
    221221        };
    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;
    224226
    225227        ndr_table_init();
    226228
    227229        /* Initialise samba stuff */
    228         load_case_tables();
     230        smb_init_locale();
    229231
    230232        setlinebuf(stdout);
     
    342344
    343345                ndr_pull = ndr_pull_init_blob(&blob, mem_ctx);
     346                if (ndr_pull == NULL) {
     347                        perror("ndr_pull_init_blob");
     348                        exit(1);
     349                }
    344350                ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC;
    345351                if (assume_ndr64) {
     
    349355                ndr_err = f->ndr_pull(ndr_pull, NDR_IN, st);
    350356
    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);
    353365                }
    354366
     
    378390
    379391        ndr_pull = ndr_pull_init_blob(&blob, mem_ctx);
     392        if (ndr_pull == NULL) {
     393                perror("ndr_pull_init_blob");
     394                exit(1);
     395        }
    380396        ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC;
    381397        if (assume_ndr64) {
     
    386402        ndr_print->print = ndr_print_printf_helper;
    387403        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);
    388423
    389424        if (out_pipes) {
     
    400435        printf("pull returned %s\n", nt_errstr(status));
    401436
    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,
    406447                             dumpdata);
    407448        }
     
    454495
    455496                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                }
    456501                ndr_v_pull->flags |= LIBNDR_FLAG_REF_ALLOC;
    457502
Note: See TracChangeset for help on using the changeset viewer.