summaryrefslogtreecommitdiff
path: root/source3/libsmb/libsmbclient.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/libsmb/libsmbclient.c')
-rw-r--r--source3/libsmb/libsmbclient.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c
index 3dec0c92b4..df9c4ddcad 100644
--- a/source3/libsmb/libsmbclient.c
+++ b/source3/libsmb/libsmbclient.c
@@ -99,7 +99,7 @@ decode_urlpart(char *segment, size_t sizeof_segment)
}
/* make a copy of the old one */
- new_usegment = (char*)malloc( old_length * 3 + 1 );
+ new_usegment = (char*)SMB_MALLOC( old_length * 3 + 1 );
while( i < old_length ) {
int bReencode = False;
@@ -671,7 +671,7 @@ SMBCSRV *smbc_server(SMBCCTX *context,
* Let's find a free server_fd
*/
- srv = (SMBCSRV *)malloc(sizeof(*srv));
+ srv = SMB_MALLOC_P(SMBCSRV);
if (!srv) {
errno = ENOMEM;
goto failed;
@@ -776,7 +776,7 @@ SMBCSRV *smbc_attr_server(SMBCCTX *context,
return NULL;
}
- ipc_srv = (SMBCSRV *)malloc(sizeof(*ipc_srv));
+ ipc_srv = SMB_MALLOC_P(SMBCSRV);
if (!ipc_srv) {
errno = ENOMEM;
cli_shutdown(ipc_cli);
@@ -871,7 +871,7 @@ static SMBCFILE *smbc_open_ctx(SMBCCTX *context, const char *fname, int flags, m
}
else {
- file = malloc(sizeof(SMBCFILE));
+ file = SMB_MALLOC_P(SMBCFILE);
if (!file) {
@@ -895,7 +895,7 @@ static SMBCFILE *smbc_open_ctx(SMBCCTX *context, const char *fname, int flags, m
/* Fill in file struct */
file->cli_fd = fd;
- file->fname = strdup(fname);
+ file->fname = SMB_STRDUP(fname);
file->srv = srv;
file->offset = 0;
file->file = True;
@@ -1629,7 +1629,7 @@ static int add_dirent(SMBCFILE *dir, const char *name, const char *comment, uint
size = sizeof(struct smbc_dirent) + u_name_len + u_comment_len + 1;
- dirent = malloc(size);
+ dirent = SMB_MALLOC(size);
if (!dirent) {
@@ -1642,7 +1642,7 @@ static int add_dirent(SMBCFILE *dir, const char *name, const char *comment, uint
if (dir->dir_list == NULL) {
- dir->dir_list = malloc(sizeof(struct smbc_dir_list));
+ dir->dir_list = SMB_MALLOC_P(struct smbc_dir_list);
if (!dir->dir_list) {
SAFE_FREE(dirent);
@@ -1656,7 +1656,7 @@ static int add_dirent(SMBCFILE *dir, const char *name, const char *comment, uint
}
else {
- dir->dir_end->next = malloc(sizeof(struct smbc_dir_list));
+ dir->dir_end->next = SMB_MALLOC_P(struct smbc_dir_list);
if (!dir->dir_end->next) {
@@ -1835,7 +1835,7 @@ static SMBCFILE *smbc_opendir_ctx(SMBCCTX *context, const char *fname)
pstrcpy(workgroup, context->workgroup);
- dir = malloc(sizeof(*dir));
+ dir = SMB_MALLOC_P(SMBCFILE);
if (!dir) {
@@ -1847,7 +1847,7 @@ static SMBCFILE *smbc_opendir_ctx(SMBCCTX *context, const char *fname)
ZERO_STRUCTP(dir);
dir->cli_fd = 0;
- dir->fname = strdup(fname);
+ dir->fname = SMB_STRDUP(fname);
dir->srv = NULL;
dir->offset = 0;
dir->file = False;
@@ -3110,7 +3110,7 @@ static BOOL add_ace(SEC_ACL **the_acl, SEC_ACE *ace, TALLOC_CTX *ctx)
return True;
}
- aces = calloc(1+(*the_acl)->num_aces,sizeof(SEC_ACE));
+ aces = SMB_CALLOC_ARRAY(SEC_ACE, 1+(*the_acl)->num_aces);
memcpy(aces, (*the_acl)->ace, (*the_acl)->num_aces * sizeof(SEC_ACE));
memcpy(aces+(*the_acl)->num_aces, ace, sizeof(SEC_ACE));
new = make_sec_acl(ctx,(*the_acl)->revision,1+(*the_acl)->num_aces, aces);
@@ -3143,7 +3143,7 @@ static SEC_DESC *sec_desc_parse(TALLOC_CTX *ctx,
}
if (StrnCaseCmp(tok,"OWNER:", 6) == 0) {
- owner_sid = (DOM_SID *)calloc(1, sizeof(DOM_SID));
+ owner_sid = SMB_CALLOC_ARRAY(DOM_SID, 1);
if (!owner_sid ||
!convert_string_to_sid(ipc_cli, pol,
numeric,
@@ -3155,7 +3155,7 @@ static SEC_DESC *sec_desc_parse(TALLOC_CTX *ctx,
}
if (StrnCaseCmp(tok,"OWNER+:", 7) == 0) {
- owner_sid = (DOM_SID *)calloc(1, sizeof(DOM_SID));
+ owner_sid = SMB_CALLOC_ARRAY(DOM_SID, 1);
if (!owner_sid ||
!convert_string_to_sid(ipc_cli, pol,
False,
@@ -3167,7 +3167,7 @@ static SEC_DESC *sec_desc_parse(TALLOC_CTX *ctx,
}
if (StrnCaseCmp(tok,"GROUP:", 6) == 0) {
- grp_sid = (DOM_SID *)calloc(1, sizeof(DOM_SID));
+ grp_sid = SMB_CALLOC_ARRAY(DOM_SID, 1);
if (!grp_sid ||
!convert_string_to_sid(ipc_cli, pol,
numeric,
@@ -3179,7 +3179,7 @@ static SEC_DESC *sec_desc_parse(TALLOC_CTX *ctx,
}
if (StrnCaseCmp(tok,"GROUP+:", 7) == 0) {
- grp_sid = (DOM_SID *)calloc(1, sizeof(DOM_SID));
+ grp_sid = SMB_CALLOC_ARRAY(DOM_SID, 1);
if (!grp_sid ||
!convert_string_to_sid(ipc_cli, pol,
False,
@@ -4273,7 +4273,7 @@ SMBCCTX * smbc_new_context(void)
{
SMBCCTX * context;
- context = malloc(sizeof(SMBCCTX));
+ context = SMB_MALLOC_P(SMBCCTX);
if (!context) {
errno = ENOMEM;
return NULL;
@@ -4281,7 +4281,7 @@ SMBCCTX * smbc_new_context(void)
ZERO_STRUCTP(context);
- context->internal = malloc(sizeof(struct smbc_internal_data));
+ context->internal = SMB_MALLOC_P(struct smbc_internal_data);
if (!context->internal) {
errno = ENOMEM;
return NULL;
@@ -4488,8 +4488,8 @@ SMBCCTX * smbc_init_context(SMBCCTX * context)
*/
user = getenv("USER");
/* walk around as "guest" if no username can be found */
- if (!user) context->user = strdup("guest");
- else context->user = strdup(user);
+ if (!user) context->user = SMB_STRDUP("guest");
+ else context->user = SMB_STRDUP(user);
}
if (!context->netbios_name) {
@@ -4498,14 +4498,14 @@ SMBCCTX * smbc_init_context(SMBCCTX * context)
* back on constructing our netbios name from our hostname etc
*/
if (global_myname()) {
- context->netbios_name = strdup(global_myname());
+ context->netbios_name = SMB_STRDUP(global_myname());
}
else {
/*
* Hmmm, I want to get hostname as well, but I am too lazy for the moment
*/
pid = sys_getpid();
- context->netbios_name = malloc(17);
+ context->netbios_name = SMB_MALLOC(17);
if (!context->netbios_name) {
errno = ENOMEM;
return NULL;
@@ -4518,11 +4518,11 @@ SMBCCTX * smbc_init_context(SMBCCTX * context)
if (!context->workgroup) {
if (lp_workgroup()) {
- context->workgroup = strdup(lp_workgroup());
+ context->workgroup = SMB_STRDUP(lp_workgroup());
}
else {
/* TODO: Think about a decent default workgroup */
- context->workgroup = strdup("samba");
+ context->workgroup = SMB_STRDUP("samba");
}
}