diff options
-rw-r--r-- | source3/client/tree.c | 2 | ||||
-rw-r--r-- | source3/lib/afs_settoken.c | 4 | ||||
-rw-r--r-- | source3/lib/sysacls.c | 61 | ||||
-rw-r--r-- | source3/lib/util_smbd.c | 4 | ||||
-rw-r--r-- | source3/libsmb/clikrb5.c | 5 | ||||
-rw-r--r-- | source3/modules/vfs_afsacl.c | 6 | ||||
-rw-r--r-- | source3/utils/editreg.c | 7 | ||||
-rw-r--r-- | source3/utils/net_rpc_samsync.c | 2 |
8 files changed, 47 insertions, 44 deletions
diff --git a/source3/client/tree.c b/source3/client/tree.c index 97ad7742e3..5071c45dbc 100644 --- a/source3/client/tree.c +++ b/source3/client/tree.c @@ -129,7 +129,7 @@ char *get_path(GtkWidget *item) struct tree_data *make_tree_data(guint32 type, const char *name) { - struct tree_data *p = (struct tree_data *)malloc(sizeof(struct tree_data)); + struct tree_data *p = SMB_MALLOC_P(struct tree_data); if (p) { diff --git a/source3/lib/afs_settoken.c b/source3/lib/afs_settoken.c index 5c646c72e4..2e74328d5d 100644 --- a/source3/lib/afs_settoken.c +++ b/source3/lib/afs_settoken.c @@ -53,7 +53,7 @@ static BOOL afs_decode_token(const char *string, char **cell, DATA_BLOB blob; struct ClearToken result_ct; - char *s = strdup(string); + char *s = SMB_STRDUP(string); char *t; @@ -62,7 +62,7 @@ static BOOL afs_decode_token(const char *string, char **cell, return False; } - *cell = strdup(t); + *cell = SMB_STRDUP(t); if ((t = strtok(NULL, "\n")) == NULL) { DEBUG(10, ("strtok failed\n")); diff --git a/source3/lib/sysacls.c b/source3/lib/sysacls.c index 9b5bef00e8..f5801af8c5 100644 --- a/source3/lib/sysacls.c +++ b/source3/lib/sysacls.c @@ -612,7 +612,7 @@ char *sys_acl_to_text(SMB_ACL_T acl_d, ssize_t *len_p) */ len = 0; maxlen = 20 * acl_d->count; - if ((text = malloc(maxlen)) == NULL) { + if ((text = SMB_MALLOC(maxlen)) == NULL) { errno = ENOMEM; return NULL; } @@ -690,7 +690,7 @@ char *sys_acl_to_text(SMB_ACL_T acl_d, ssize_t *len_p) maxlen += nbytes + 20 * (acl_d->count - i); - if ((text = Realloc(oldtext, maxlen)) == NULL) { + if ((text = SMB_REALLOC(oldtext, maxlen)) == NULL) { SAFE_FREE(oldtext); errno = ENOMEM; return NULL; @@ -722,7 +722,7 @@ SMB_ACL_T sys_acl_init(int count) * acl[] array, this actually allocates an ACL with room * for (count+1) entries */ - if ((a = malloc(sizeof(*a) + count * sizeof(struct acl))) == NULL) { + if ((a = SMB_MALLOC(sizeof(*a) + count * sizeof(struct acl))) == NULL) { errno = ENOMEM; return NULL; } @@ -886,7 +886,7 @@ int sys_acl_set_file(const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d) * allocate a temporary buffer for the complete ACL */ acl_count = acc_acl->count + def_acl->count; - acl_p = acl_buf = malloc(acl_count * sizeof(acl_buf[0])); + acl_p = acl_buf = SMB_MALLOC_ARRAY(struct acl, acl_count); if (acl_buf == NULL) { sys_acl_free_acl(tmp_acl); @@ -1243,7 +1243,7 @@ char *sys_acl_to_text(SMB_ACL_T acl_d, ssize_t *len_p) */ len = 0; maxlen = 20 * acl_d->count; - if ((text = malloc(maxlen)) == NULL) { + if ((text = SMB_MALLOC(maxlen)) == NULL) { errno = ENOMEM; return NULL; } @@ -1321,7 +1321,7 @@ char *sys_acl_to_text(SMB_ACL_T acl_d, ssize_t *len_p) maxlen += nbytes + 20 * (acl_d->count - i); - if ((text = Realloc(oldtext, maxlen)) == NULL) { + if ((text = SMB_REALLOC(oldtext, maxlen)) == NULL) { free(oldtext); errno = ENOMEM; return NULL; @@ -1353,7 +1353,7 @@ SMB_ACL_T sys_acl_init(int count) * acl[] array, this actually allocates an ACL with room * for (count+1) entries */ - if ((a = malloc(sizeof(*a) + count * sizeof(struct acl))) == NULL) { + if ((a = SMB_MALLOC(sizeof(*a) + count * sizeof(struct acl))) == NULL) { errno = ENOMEM; return NULL; } @@ -1819,7 +1819,7 @@ int sys_acl_set_file(const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d) * allocate a temporary buffer for the complete ACL */ acl_count = acc_acl->count + def_acl->count; - acl_p = acl_buf = malloc(acl_count * sizeof(acl_buf[0])); + acl_p = acl_buf = SMB_MALLOC_ARRAY(struct acl, acl_count); if (acl_buf == NULL) { sys_acl_free_acl(tmp_acl); @@ -1982,7 +1982,7 @@ SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type) { SMB_ACL_T a; - if ((a = malloc(sizeof(*a))) == NULL) { + if ((a = SMB_MALLOC_P(SMB_ACL_T)) == NULL) { errno = ENOMEM; return NULL; } @@ -1999,7 +1999,7 @@ SMB_ACL_T sys_acl_get_fd(int fd) { SMB_ACL_T a; - if ((a = malloc(sizeof(*a))) == NULL) { + if ((a = SMB_MALLOC_P(SMB_ACL_T)) == NULL) { errno = ENOMEM; return NULL; } @@ -2056,7 +2056,7 @@ SMB_ACL_T sys_acl_init(int count) return NULL; } - if ((a = malloc(sizeof(*a) + sizeof(struct acl))) == NULL) { + if ((a = SMB_MALLOC_P(struct acl)) == NULL) { errno = ENOMEM; return NULL; } @@ -2282,7 +2282,7 @@ SMB_ACL_T sys_acl_get_file( const char *path_p, SMB_ACL_TYPE_T type) DEBUG(10,("Entering sys_acl_get_file\n")); DEBUG(10,("path_p is %s\n",path_p)); - file_acl = (struct acl *)malloc(BUFSIZ); + file_acl = (struct acl *)SMB_MALLOC(BUFSIZ); if(file_acl == NULL) { errno=ENOMEM; @@ -2313,7 +2313,7 @@ SMB_ACL_T sys_acl_get_file( const char *path_p, SMB_ACL_TYPE_T type) if(acl_entry_link_head == NULL) return(NULL); - acl_entry_link->entryp = (struct new_acl_entry *)malloc(sizeof(struct new_acl_entry)); + acl_entry_link->entryp = SMB_MALLOC_P(struct new_acl_entry); if(acl_entry_link->entryp == NULL) { SAFE_FREE(file_acl); errno = ENOMEM; @@ -2348,8 +2348,7 @@ SMB_ACL_T sys_acl_get_file( const char *path_p, SMB_ACL_TYPE_T type) * and already has entryp allocated. */ if(acl_entry_link_head->count != 0) { - acl_entry_link->nextp = (struct acl_entry_link *) - malloc(sizeof(struct acl_entry_link)); + acl_entry_link->nextp = SMB_MALLOC_P(struct acl_entry_link); if(acl_entry_link->nextp == NULL) { SAFE_FREE(file_acl); @@ -2360,7 +2359,7 @@ SMB_ACL_T sys_acl_get_file( const char *path_p, SMB_ACL_TYPE_T type) acl_entry_link->nextp->prevp = acl_entry_link; acl_entry_link = acl_entry_link->nextp; - acl_entry_link->entryp = (struct new_acl_entry *)malloc(sizeof(struct new_acl_entry)); + acl_entry_link->entryp = SMB_MALLOC_P(struct new_acl_entry); if(acl_entry_link->entryp == NULL) { SAFE_FREE(file_acl); errno = ENOMEM; @@ -2419,7 +2418,7 @@ SMB_ACL_T sys_acl_get_file( const char *path_p, SMB_ACL_TYPE_T type) for( i = 1; i < 4; i++) { DEBUG(10,("i is %d\n",i)); if(acl_entry_link_head->count != 0) { - acl_entry_link->nextp = (struct acl_entry_link *)malloc(sizeof(struct acl_entry_link)); + acl_entry_link->nextp = SMB_MALLOC_P(struct acl_entry_link); if(acl_entry_link->nextp == NULL) { SAFE_FREE(file_acl); errno = ENOMEM; @@ -2429,7 +2428,7 @@ SMB_ACL_T sys_acl_get_file( const char *path_p, SMB_ACL_TYPE_T type) acl_entry_link->nextp->prevp = acl_entry_link; acl_entry_link = acl_entry_link->nextp; - acl_entry_link->entryp = (struct new_acl_entry *)malloc(sizeof(struct new_acl_entry)); + acl_entry_link->entryp = SMB_MALLOC_P(struct new_acl_entry); if(acl_entry_link->entryp == NULL) { SAFE_FREE(file_acl); errno = ENOMEM; @@ -2496,7 +2495,7 @@ SMB_ACL_T sys_acl_get_fd(int fd) DEBUG(10,("Entering sys_acl_get_fd\n")); DEBUG(10,("fd is %d\n",fd)); - file_acl = (struct acl *)malloc(BUFSIZ); + file_acl = (struct acl *)SMB_MALLOC(BUFSIZ); if(file_acl == NULL) { errno=ENOMEM; @@ -2529,7 +2528,7 @@ SMB_ACL_T sys_acl_get_fd(int fd) return(NULL); } - acl_entry_link->entryp = (struct new_acl_entry *)malloc(sizeof(struct new_acl_entry)); + acl_entry_link->entryp = SMB_MALLOC_P(struct new_acl_entry); if(acl_entry_link->entryp == NULL) { errno = ENOMEM; @@ -2566,7 +2565,7 @@ SMB_ACL_T sys_acl_get_fd(int fd) * and already has entryp allocated. */ if(acl_entry_link_head->count != 0) { - acl_entry_link->nextp = (struct acl_entry_link *)malloc(sizeof(struct acl_entry_link)); + acl_entry_link->nextp = SMB_MALLOC_P(struct acl_entry_link); if(acl_entry_link->nextp == NULL) { errno = ENOMEM; DEBUG(0,("Error in sys_acl_get_fd is %d\n",errno)); @@ -2575,7 +2574,7 @@ SMB_ACL_T sys_acl_get_fd(int fd) } acl_entry_link->nextp->prevp = acl_entry_link; acl_entry_link = acl_entry_link->nextp; - acl_entry_link->entryp = (struct new_acl_entry *)malloc(sizeof(struct new_acl_entry)); + acl_entry_link->entryp = SMB_MALLOC_P(struct new_acl_entry); if(acl_entry_link->entryp == NULL) { errno = ENOMEM; DEBUG(0,("Error in sys_acl_get_fd is %d\n",errno)); @@ -2634,7 +2633,7 @@ SMB_ACL_T sys_acl_get_fd(int fd) for( i = 1; i < 4; i++) { DEBUG(10,("i is %d\n",i)); if(acl_entry_link_head->count != 0){ - acl_entry_link->nextp = (struct acl_entry_link *)malloc(sizeof(struct acl_entry_link)); + acl_entry_link->nextp = SMB_MALLOC_P(struct acl_entry_link); if(acl_entry_link->nextp == NULL) { errno = ENOMEM; DEBUG(0,("Error in sys_acl_get_fd is %d\n",errno)); @@ -2644,7 +2643,7 @@ SMB_ACL_T sys_acl_get_fd(int fd) acl_entry_link->nextp->prevp = acl_entry_link; acl_entry_link = acl_entry_link->nextp; - acl_entry_link->entryp = (struct new_acl_entry *)malloc(sizeof(struct new_acl_entry)); + acl_entry_link->entryp = SMB_MALLOC_P(struct new_acl_entry); if(acl_entry_link->entryp == NULL) { SAFE_FREE(file_acl); @@ -2723,7 +2722,7 @@ SMB_ACL_T sys_acl_init( int count) DEBUG(10,("Entering sys_acl_init\n")); - theacl = (struct acl_entry_link *)malloc(sizeof(struct acl_entry_link)); + theacl = SMB_MALLOC_P(struct acl_entry_link); if(theacl == NULL) { errno = ENOMEM; DEBUG(0,("Error in sys_acl_init is %d\n",errno)); @@ -2758,7 +2757,7 @@ int sys_acl_create_entry( SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry) } if(theacl->count != 0){ - temp_entry->nextp = acl_entryp = (struct acl_entry_link *)malloc(sizeof(struct acl_entry_link)); + temp_entry->nextp = acl_entryp = SMB_MALLOC_P(struct acl_entry_link); if(acl_entryp == NULL) { errno = ENOMEM; DEBUG(0,("Error in sys_acl_create_entry is %d\n",errno)); @@ -2770,7 +2769,7 @@ int sys_acl_create_entry( SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry) DEBUG(10,("The acl_entryp->prevp is %d\n",acl_entryp->prevp)); } - *pentry = acl_entryp->entryp = (struct new_acl_entry *)malloc(sizeof(struct new_acl_entry)); + *pentry = acl_entryp->entryp = SMB_MALLOC_P(struct new_acl_entry); if(*pentry == NULL) { errno = ENOMEM; DEBUG(0,("Error in sys_acl_create_entry is %d\n",errno)); @@ -2860,7 +2859,7 @@ int sys_acl_set_file( const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl return(0); acl_length = BUFSIZ; - file_acl = (struct acl *)malloc(BUFSIZ); + file_acl = (struct acl *)SMB_MALLOC(BUFSIZ); if(file_acl == NULL) { errno = ENOMEM; @@ -2893,7 +2892,7 @@ int sys_acl_set_file( const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl if((file_acl->acl_len + sizeof(struct acl_entry)) > acl_length) { acl_length += sizeof(struct acl_entry); - file_acl_temp = (struct acl *)malloc(acl_length); + file_acl_temp = (struct acl *)SMB_MALLOC(acl_length); if(file_acl_temp == NULL) { SAFE_FREE(file_acl); errno = ENOMEM; @@ -2948,7 +2947,7 @@ int sys_acl_set_fd( int fd, SMB_ACL_T theacl) DEBUG(10,("Entering sys_acl_set_fd\n")); acl_length = BUFSIZ; - file_acl = (struct acl *)malloc(BUFSIZ); + file_acl = (struct acl *)SMB_MALLOC(BUFSIZ); if(file_acl == NULL) { errno = ENOMEM; @@ -2982,7 +2981,7 @@ int sys_acl_set_fd( int fd, SMB_ACL_T theacl) if((file_acl->acl_len + sizeof(struct acl_entry)) > acl_length) { acl_length += sizeof(struct acl_entry); - file_acl_temp = (struct acl *)malloc(acl_length); + file_acl_temp = (struct acl *)SMB_MALLOC(acl_length); if(file_acl_temp == NULL) { SAFE_FREE(file_acl); errno = ENOMEM; diff --git a/source3/lib/util_smbd.c b/source3/lib/util_smbd.c index fdb4cb3385..2eb0bb7cc0 100644 --- a/source3/lib/util_smbd.c +++ b/source3/lib/util_smbd.c @@ -45,7 +45,7 @@ BOOL getgroups_user(const char *user, gid_t primary_gid, gid_t **ret_groups, int int i; max_grp = groups_max(); - temp_groups = (gid_t *)malloc(sizeof(gid_t) * max_grp); + temp_groups = SMB_MALLOC_P(gid_t, max_grp); if (! temp_groups) { return False; } @@ -54,7 +54,7 @@ BOOL getgroups_user(const char *user, gid_t primary_gid, gid_t **ret_groups, int gid_t *groups_tmp; - groups_tmp = Realloc(temp_groups, sizeof(gid_t) * max_grp); + groups_tmp = SMB_REALLOC(temp_groups, gid_t, max_grp); if (!groups_tmp) { SAFE_FREE(temp_groups); diff --git a/source3/libsmb/clikrb5.c b/source3/libsmb/clikrb5.c index 15be8967b8..66c16b69ae 100644 --- a/source3/libsmb/clikrb5.c +++ b/source3/libsmb/clikrb5.c @@ -233,7 +233,7 @@ return -1; } - sa = malloc( sizeof(struct sockaddr) * num_kdcs ); + sa = SMB_MALLOC_ARRAY( struct sockaddr, num_kdcs ); if (!sa) { DEBUG(0, ("krb5_locate_kdc: malloc failed\n")); krb5_krbhst_free(ctx, hnd); @@ -241,8 +241,7 @@ return -1; } - *addr_pp = malloc(sizeof(struct sockaddr) * num_kdcs); - memset(*addr_pp, '\0', sizeof(struct sockaddr) * num_kdcs ); + memset(sa, '\0', sizeof(struct sockaddr) * num_kdcs ); for (i = 0; i < num_kdcs && (rc = krb5_krbhst_next(ctx, hnd, &hinfo) == 0); i++) { diff --git a/source3/modules/vfs_afsacl.c b/source3/modules/vfs_afsacl.c index bb82801a00..6d6848eb12 100644 --- a/source3/modules/vfs_afsacl.c +++ b/source3/modules/vfs_afsacl.c @@ -85,7 +85,7 @@ static void free_afs_acl(struct afs_acl *acl) static struct afs_ace *clone_afs_ace(TALLOC_CTX *mem_ctx, struct afs_ace *ace) { - struct afs_ace *result = talloc(mem_ctx, sizeof(struct afs_ace)); + struct afs_ace *result = TALLOC_P(mem_ctx, struct afs_ace); if (result == NULL) return NULL; @@ -169,7 +169,7 @@ static struct afs_ace *new_afs_ace(TALLOC_CTX *mem_ctx, } } - result = talloc(mem_ctx, sizeof(struct afs_ace)); + result = TALLOC_P(mem_ctx, struct afs_ace); if (result == NULL) { DEBUG(0, ("Could not talloc AFS ace\n")); @@ -619,7 +619,7 @@ static size_t afs_to_nt_acl(struct afs_acl *afs_acl, uid_to_sid(&owner_sid, sbuf.st_uid); gid_to_sid(&group_sid, sbuf.st_gid); - nt_ace_list = (SEC_ACE *)malloc(afs_acl->num_aces * sizeof(SEC_ACE)); + nt_ace_list = SMB_MALLOC_ARRAY(SEC_ACE, afs_acl->num_aces); if (nt_ace_list == NULL) return 0; diff --git a/source3/utils/editreg.c b/source3/utils/editreg.c index fa930b163a..9123de18c8 100644 --- a/source3/utils/editreg.c +++ b/source3/utils/editreg.c @@ -302,6 +302,7 @@ Hope this helps.... (Although it was "fun" for me to uncover this things, *************************************************************************/ +#ifdef STANDALONE #include <stdio.h> #include <stdlib.h> #include <errno.h> @@ -315,6 +316,10 @@ Hope this helps.... (Although it was "fun" for me to uncover this things, #define False 0 #define True 1 +#else /* STANDALAONE */ +#include "includes.h" +#endif /* STANDALONE */ + #define REG_KEY_LIST_SIZE 10 /* @@ -1900,7 +1905,7 @@ SEC_DESC *process_sec_desc(REGF *regf, REG_SEC_DESC *sec_desc) { SEC_DESC *tmp = NULL; - tmp = (SEC_DESC *)malloc(sizeof(SEC_DESC)); + tmp = SMB_MALLOC_P(SEC_DESC); if (!tmp) { return NULL; diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c index 3c98ec9e71..e8a110d083 100644 --- a/source3/utils/net_rpc_samsync.c +++ b/source3/utils/net_rpc_samsync.c @@ -863,7 +863,7 @@ fetch_alias_mem(uint32 rid, SAM_ALIAS_MEM_INFO *delta, DOM_SID dom_sid) return NT_STATUS_NO_MEMORY; } - nt_members = talloc_zero(t, sizeof(char *) * delta->num_members); + nt_members = TALLOC_ZERO_ARRAY(t, char *, delta->num_members); for (i=0; i<delta->num_members; i++) { NTSTATUS nt_status; |