Exemple #1
0
static long _srp_bytes_container_allocate(
    const char *data,
    long data_len,
    rpc_p_srp_bytes_container *ret_cont)
{
    long sts = 0;
    rpc_p_srp_bytes_container cont = NULL;

    cont = rpc_ss_allocate(sizeof(rpc_srp_bytes_container));
    if (!cont)
    {
        sts = rpc_s_no_memory;
        goto error;
    }

    cont->bytes_B = rpc_ss_allocate(data_len * sizeof(char));
    if (!cont->bytes_B)
    {
        sts = rpc_s_no_memory;
        goto error;
    }
    if (data && data_len > 0)
    {
        memcpy(cont->bytes_B, data, data_len);
        cont->len_B = data_len;
    }
    else
    {
        cont->len_B = 0;
    }

    *ret_cont = cont;

error:
    if (sts)
    {
        _srp_bytes_container_free(cont);
    }
    return sts;
}
Exemple #2
0
DWORD
VMCARpcAllocateMemory(
    size_t size,
    PVOID* ppMemory
    )
{
    DWORD dwError = 0;
    PVOID pMemory = NULL;

    if (size <= 0 || !ppMemory)
    {
        dwError = ERROR_INVALID_PARAMETER;
        BAIL_ON_VMCA_ERROR(dwError);
    }

    pMemory = rpc_ss_allocate((idl_size_t)size);
    if (!pMemory)
    {
        dwError = ERROR_OUTOFMEMORY;
        BAIL_ON_VMCA_ERROR(dwError);
    }

    memset(pMemory,0, size);
    *ppMemory = pMemory;

cleanup:

    return dwError;

error:

    if (ppMemory)
    {
        *ppMemory = NULL;
    }

    goto cleanup;
}
Exemple #3
0
NTSTATUS
LsaSrvAllocateMemory(
    void **ppOut,
    DWORD dwSize
    )
{
    NTSTATUS ntStatus = STATUS_SUCCESS;
    void *pOut = NULL;

    pOut = rpc_ss_allocate(dwSize);
    BAIL_ON_NO_MEMORY(pOut);

    memset(pOut, 0, dwSize);

    *ppOut = pOut;

cleanup:
    return ntStatus;

error:
    *ppOut = NULL;
    goto cleanup;
}
idl_boolean
ReverseIt(
    rpc_binding_handle_t h,
    args * in_text,
    args ** out_text,
    error_status_t * status
    )
{

    char * binding_info;
    error_status_t e;
    unsigned result_size;
    args * result;
    unsigned32 i,j,l;
    rpc_transport_info_handle_t transport_info = NULL;
    unsigned32 rpcstatus = 0;

#if 0
    unsigned char* sesskey = NULL;
    unsigned32 sesskey_len = 0;
    unsigned char* principal_name = NULL;
#endif

    /*
     * Get some info about the client binding
     */

    rpc_binding_to_string_binding(h, (unsigned char **)&binding_info, &e);
    if (e == rpc_s_ok)
    {
        printf ("ReverseIt() called by client: %s\n", binding_info);
    }

    rpc_binding_inq_transport_info(h, &transport_info, &rpcstatus);

    /* SMB transport session calls temporarily disabled */
#if 0
    if (transport_info)
    {
        rpc_smb_transport_info_inq_peer_principal_name(transport_info, &principal_name);
        rpc_smb_transport_info_inq_session_key(transport_info, &sesskey, &sesskey_len);

        printf ("Client principal name: %s\n", (char*) principal_name);
        printf ("Session key: ");

        for (i = 0; i < sesskey_len; i++)
        {
            printf("%X", sesskey[i]);
        }

        printf ("\n");
    }

#endif /* 0 */

    if (in_text == NULL) return 0;

    /*
     *  Print the in_text
     */

    printf("\n\nFunction ReverseIt() -- input argments\n");

    for (i=0; i<in_text->argc; i++)
        printf("\t[arg %d]: %s\n", i, in_text->argv[i]);

    printf ("\n=========================================\n");

    /*
     * Allocate the output args as dynamic storage bound
     * to this RPC. The output args are the same size as the
     * input args since we are simply reversing strings.
     */

    result_size = sizeof(args) + in_text->argc * sizeof(string_t *);
    result = (args * )rpc_ss_allocate(result_size);
    result->argc = in_text->argc;

    for (i=0; i < in_text->argc; i++)
    {
        result->argv[i] =
            (string_t)rpc_ss_allocate(strlen((const char *)in_text->argv[i]) + 1);
    }

    /*
     * do the string reversal
     */

    for (i=0; i < in_text->argc; i++)
    {
        l = strlen((const char *)in_text->argv[i]);
        for (j=0; j<l; j++)
        {
            result->argv[i][j] = in_text->argv[i][l-j-1];
        }
        result->argv[i][l]=0;           /* make sure its null terminated! */
    }

    *out_text = result;
    *status = error_status_ok;

    return 1;
}