*
* 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 2 of the License, or
+ * 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,
* 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, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "libmsrpc.h"
#include "libmsrpc_internal.h"
+char *cac_unistr_to_str( TALLOC_CTX * mem_ctx, uint16 * src, int num_bytes );
+char *talloc_unistr2_to_ascii( TALLOC_CTX * mem_ctx, UNISTR2 str );
+char *cac_unistr_ascii( TALLOC_CTX * mem_ctx, UNISTR src );
+
/*used to get a struct rpc_pipe_client* to be passed into rpccli* calls*/
struct rpc_pipe_client *cac_GetPipe( CacServerHandle * hnd, int pi_idx )
{
/*need room for a '\0' */
str_len++;
- buf = talloc_array( mem_ctx, char, str_len );
+ buf = TALLOC_ARRAY( mem_ctx, char, str_len );
if ( !buf ) {
return NULL;
data->reg_binary.data_length = size;
- data->reg_binary.data =
- ( uint8 * ) talloc_memdup( mem_ctx, buf.buffer,
- size );
- if ( !data->reg_binary.data ) {
- TALLOC_FREE( data );
- errno = ENOMEM;
- data = NULL;
+ if (size) {
+ data->reg_binary.data =
+ ( uint8 * ) TALLOC_MEMDUP( mem_ctx, buf.buffer, size );
+ if ( !data->reg_binary.data ) {
+ TALLOC_FREE( data );
+ errno = ENOMEM;
+ data = NULL;
+ }
+ } else {
+ data->reg_binary.data = NULL;
}
break;
break;
}
- strings = talloc_array( mem_ctx, char *, num_strings );
+ if (num_strings) {
+ strings = TALLOC_ARRAY( mem_ctx, char *, num_strings );
- if ( !strings ) {
- errno = ENOMEM;
- TALLOC_FREE( data );
- break;
+ if ( !strings ) {
+ errno = ENOMEM;
+ TALLOC_FREE( data );
+ break;
+ }
+ } else {
+ strings = NULL;
}
if ( num_strings == 0 ) /*then our work here is done */
if ( !mem_ctx )
return NULL;
- buf = talloc_array( mem_ctx, char, ( str.uni_str_len + 1 ) );
+ buf = TALLOC_ARRAY( mem_ctx, char, ( str.uni_str_len + 1 ) );
if ( !buf )
return NULL;
memcpy( info->lm_password, id21->lm_pwd, 8 );
info->logon_hours =
- ( LOGON_HRS * ) talloc_memdup( mem_ctx, &( id21->logon_hrs ),
+ ( LOGON_HRS * ) TALLOC_MEMDUP( mem_ctx, &( id21->logon_hrs ),
sizeof( LOGON_HRS ) );
if ( !info->logon_hours )
return NULL;
if ( !mem_ctx || !svc )
return NULL;
- services = TALLOC_ZERO_ARRAY( mem_ctx, CacService, num_services );
- if ( !services )
- return NULL;
+ if (num_services) {
+ services = TALLOC_ZERO_ARRAY( mem_ctx, CacService, num_services );
+ if ( !services )
+ return NULL;
+ } else {
+ services = NULL;
+ }
for ( i = 0; i < num_services; i++ ) {
services[i].service_name =