On Fri, Dec 17, 2004 at 08:42:12AM +0100, Ralf S. Engelschall wrote:
> On Thu, Dec 16, 2004, David M. Fetter wrote:
> 
> > In case you guys weren't aware of this.  Also, I will be working on
> > adding ads support into the samba openpkg rpm in the near future.
> > [...]
> 
> We know about the issue and working on it, but yesterday
> we first have done the PHP issues...

We took a look at your backported CAN-2004-1154 patch for 3.0.4 to
compare to the backport we did for 3.0.5 (similar except for
differences between 3.0.4/3.0.5). We've found some additional cases
the Samba developers missed. I've attached the additional patch we're
using for 3.0.5 and 3.0.10. There's also a fix for a memory leak in
source/libsmb/clikrb5.c. I don't know if these additional patches are
cause for concern.

The additional patches are now part of the SAMBA_3_0 branch.

-- 
albert chin ([EMAIL PROTECTED])
--- source/smbd/quotas.c.orig   Mon Dec 20 19:59:09 2004
+++ source/smbd/quotas.c        Mon Dec 20 19:59:23 2004
@@ -471,7 +471,7 @@
 
        len=strcspn(mnttype, ":");
        pathname=strstr(mnttype, ":");
-       cutstr = (char *) malloc(len+1);
+       cutstr = (char *) SMB_MALLOC(len+1);
        if (!cutstr)
                return False;
 
--- source/printing/print_svid.c.orig   Tue Jul 20 11:27:59 2004
+++ source/printing/print_svid.c        Mon Dec 20 16:04:37 2004
@@ -88,7 +88,7 @@
                        *tmp = '\0';
                
                /* add it to the cache */
-               if ((ptmp = malloc(sizeof (*ptmp))) != NULL) {
+               if ((ptmp = SMB_MALLOC_P(printer_t)) != NULL) {
                        ZERO_STRUCTP(ptmp);
                        if((ptmp->name = strdup(name)) == NULL)
                                DEBUG(0,("populate_printers: malloc fail in 
strdup !\n"));
--- source/lib/sysacls.c.orig   Tue Jul 20 11:28:03 2004
+++ source/lib/sysacls.c        Mon Dec 20 16:04:32 2004
@@ -612,7 +612,7 @@
         */
        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 @@
 
                        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 @@
         * 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(struct SMB_ACL_T) + count * sizeof(struct 
acl))) == NULL) {
                errno = ENOMEM;
                return NULL;
        }
@@ -886,7 +886,7 @@
                 * 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 @@
         */
        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 @@
 
                        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 @@
         * 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(struct SMB_ACL_T) + count * sizeof(struct 
acl))) == NULL) {
                errno = ENOMEM;
                return NULL;
        }
@@ -1819,7 +1819,7 @@
                 * 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       a;
 
-       if ((a = malloc(sizeof(*a))) == NULL) {
+       if ((a = SMB_MALLOC_P(struct SMB_ACL_T)) == NULL) {
                errno = ENOMEM;
                return NULL;
        }
@@ -1999,7 +1999,7 @@
 {
        SMB_ACL_T       a;
 
-       if ((a = malloc(sizeof(*a))) == NULL) {
+       if ((a = SMB_MALLOC_P(struct SMB_ACL_T)) == NULL) {
                errno = ENOMEM;
                return NULL;
        }
@@ -2056,7 +2056,7 @@
                return NULL;
        }
 
-       if ((a = malloc(sizeof(*a) + sizeof(struct acl))) == NULL) {
+       if ((a = SMB_MALLOC(sizeof(struct SMB_ACL_T) + sizeof(struct acl))) == 
NULL) {
                errno = ENOMEM;
                return NULL;
        }
@@ -2282,7 +2282,7 @@
        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 @@
        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 @@
                         * 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 @@
 
                                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 @@
        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 @@
 
                        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 @@
    
        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 @@
                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 @@
                         * 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 @@
                                }
                                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 @@
        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 @@
 
                        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 @@
  
        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 @@
        }
 
        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 @@
                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 @@
                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 @@
 
                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 @@
  
        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 @@
 
                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;
--- source/lib/afs_settoken.c.orig      Tue Jul 20 11:28:04 2004
+++ source/lib/afs_settoken.c   Mon Dec 20 16:04:32 2004
@@ -49,7 +49,7 @@
        DATA_BLOB blob;
        struct ClearToken result_ct;
 
-       char *s = strdup(string);
+       char *s = SMB_STRDUP(string);
 
        char *t;
 
@@ -58,7 +58,7 @@
                return False;
        }
 
-       *cell = strdup(t);
+       *cell = SMB_STRDUP(t);
 
        if ((t = strtok(NULL, "\n")) == NULL) {
                DEBUG(10, ("strtok failed\n"));
--- source/libsmb/clikrb5.c.orig        Tue Jul 20 11:28:04 2004
+++ source/libsmb/clikrb5.c     Mon Dec 20 16:05:22 2004
@@ -211,7 +211,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);
@@ -219,7 +219,7 @@
                return -1;
        }
 
-       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++) {
                if (hinfo->ai->ai_family == AF_INET)
--- source/utils/editreg.c.orig Tue Jul 20 11:28:15 2004
+++ source/utils/editreg.c      Mon Dec 20 16:04:37 2004
@@ -302,6 +302,7 @@
 
 *************************************************************************/
 
+#ifdef STANDALONE
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
@@ -315,6 +316,10 @@
 
 #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 *tmp = NULL;
   
-  tmp = (SEC_DESC *)malloc(sizeof(SEC_DESC));
+  tmp = SMB_MALLOC_P(SEC_DESC);
 
   if (!tmp) {
     return NULL;
--- source/utils/net_rpc_samsync.c.orig Mon Dec 20 16:02:17 2004
+++ source/utils/net_rpc_samsync.c      Mon Dec 20 16:04:37 2004
@@ -795,7 +795,7 @@
                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;
--- source/client/tree.c.orig   Tue Jul 20 11:28:17 2004
+++ source/client/tree.c        Mon Dec 20 16:04:37 2004
@@ -129,7 +129,7 @@
 
 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) {
 
--- source/smbd/quotas.c.orig   Mon Dec 20 20:02:35 2004
+++ source/smbd/quotas.c        Mon Dec 20 20:02:47 2004
@@ -471,7 +471,7 @@
 
        len=strcspn(mnttype, ":");
        pathname=strstr(mnttype, ":");
-       cutstr = (char *) malloc(len+1);
+       cutstr = (char *) SMB_MALLOC(len+1);
        if (!cutstr)
                return False;
 
@@ -1000,7 +1000,7 @@
 
        len=strcspn(mnttype, ":");
        pathname=strstr(mnttype, ":");
-       cutstr = (char *) malloc(len+1);
+       cutstr = (char *) SMB_MALLOC(len+1);
        if (!cutstr)
                return False;
 
--- source/printing/print_svid.c.orig   Mon Oct 25 16:04:55 2004
+++ source/printing/print_svid.c        Mon Dec 20 20:02:29 2004
@@ -88,7 +88,7 @@
                        *tmp = '\0';
                
                /* add it to the cache */
-               if ((ptmp = malloc(sizeof (*ptmp))) != NULL) {
+               if ((ptmp = SMB_MALLOC_P(printer_t)) != NULL) {
                        ZERO_STRUCTP(ptmp);
                        if((ptmp->name = strdup(name)) == NULL)
                                DEBUG(0,("populate_printers: malloc fail in 
strdup !\n"));
--- source/lib/sysacls.c.orig   Wed Dec 15 08:12:15 2004
+++ source/lib/sysacls.c        Mon Dec 20 20:02:28 2004
@@ -612,7 +612,7 @@
         */
        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 @@
 
                        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 @@
         * 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(struct SMB_ACL_T) + count * sizeof(struct 
acl))) == NULL) {
                errno = ENOMEM;
                return NULL;
        }
@@ -886,7 +886,7 @@
                 * 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 @@
         */
        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 @@
 
                        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 @@
         * 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(struct SMB_ACL_T) + count * sizeof(struct 
acl))) == NULL) {
                errno = ENOMEM;
                return NULL;
        }
@@ -1819,7 +1819,7 @@
                 * 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       a;
 
-       if ((a = malloc(sizeof(*a))) == NULL) {
+       if ((a = SMB_MALLOC_P(struct SMB_ACL_T)) == NULL) {
                errno = ENOMEM;
                return NULL;
        }
@@ -1999,7 +1999,7 @@
 {
        SMB_ACL_T       a;
 
-       if ((a = malloc(sizeof(*a))) == NULL) {
+       if ((a = SMB_MALLOC_P(struct SMB_ACL_T)) == NULL) {
                errno = ENOMEM;
                return NULL;
        }
@@ -2056,7 +2056,7 @@
                return NULL;
        }
 
-       if ((a = malloc(sizeof(*a) + sizeof(struct acl))) == NULL) {
+       if ((a = SMB_MALLOC(sizeof(struct SMB_ACL_T) + sizeof(struct acl))) == 
NULL) {
                errno = ENOMEM;
                return NULL;
        }
@@ -2282,7 +2282,7 @@
        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 @@
        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 @@
                         * 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 @@
 
                                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 @@
        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 @@
 
                        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 @@
    
        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 @@
                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 @@
                         * 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 @@
                                }
                                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 @@
        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 @@
 
                        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 @@
  
        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 @@
        }
 
        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 @@
                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 @@
                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 @@
 
                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 @@
  
        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 @@
 
                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;
--- source/lib/afs_settoken.c.orig      Mon Oct 25 16:05:00 2004
+++ source/lib/afs_settoken.c   Mon Dec 20 20:02:28 2004
@@ -53,7 +53,7 @@
        DATA_BLOB blob;
        struct ClearToken result_ct;
 
-       char *s = strdup(string);
+       char *s = SMB_STRDUP(string);
 
        char *t;
 
@@ -62,7 +62,7 @@
                return False;
        }
 
-       *cell = strdup(t);
+       *cell = SMB_STRDUP(t);
 
        if ((t = strtok(NULL, "\n")) == NULL) {
                DEBUG(10, ("strtok failed\n"));
--- source/libsmb/clikrb5.c.orig        Sun Nov  7 14:43:23 2004
+++ source/libsmb/clikrb5.c     Mon Dec 20 20:02:28 2004
@@ -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++) {
 
--- source/modules/vfs_afsacl.c.orig    Mon Oct 25 16:05:01 2004
+++ source/modules/vfs_afsacl.c Mon Dec 20 20:02:28 2004
@@ -83,7 +83,7 @@
 
 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;
@@ -167,7 +167,7 @@
                }
        }
 
-       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"));
@@ -599,7 +599,7 @@
        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;
--- source/utils/editreg.c.orig Mon Oct 25 16:05:09 2004
+++ source/utils/editreg.c      Mon Dec 20 20:02:29 2004
@@ -302,6 +302,7 @@
 
 *************************************************************************/
 
+#ifdef STANDALONE
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
@@ -315,6 +316,10 @@
 
 #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 *tmp = NULL;
   
-  tmp = (SEC_DESC *)malloc(sizeof(SEC_DESC));
+  tmp = SMB_MALLOC_P(SEC_DESC);
 
   if (!tmp) {
     return NULL;
--- source/utils/net_rpc_samsync.c.orig Wed Dec 15 08:33:18 2004
+++ source/utils/net_rpc_samsync.c      Mon Dec 20 20:02:29 2004
@@ -795,7 +795,7 @@
                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;
--- source/client/tree.c.orig   Mon Oct 25 16:05:11 2004
+++ source/client/tree.c        Mon Dec 20 20:02:29 2004
@@ -129,7 +129,7 @@
 
 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) {
 

Reply via email to