svn commit: samba r16606 - in branches/SAMBA_3_0/source/libsmb: .

jra at samba.org jra at samba.org
Wed Jun 28 04:27:44 GMT 2006


Author: jra
Date: 2006-06-28 04:27:43 +0000 (Wed, 28 Jun 2006)
New Revision: 16606

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16606

Log:
Klocwork #1990. Malloc the correct size.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/libsmb/clirap2.c


Changeset:
Modified: branches/SAMBA_3_0/source/libsmb/clirap2.c
===================================================================
--- branches/SAMBA_3_0/source/libsmb/clirap2.c	2006-06-28 04:27:37 UTC (rev 16605)
+++ branches/SAMBA_3_0/source/libsmb/clirap2.c	2006-06-28 04:27:43 UTC (rev 16606)
@@ -211,12 +211,21 @@
 	    +WORDSIZE                    /* info level    */
 	    +WORDSIZE];                  /* reserved word */
 
-  char data[1024];
-    
   /* offset into data of free format strings.  Will be updated */
   /* by PUTSTRINGP macro and end up with total data length.    */
   int soffset = RAP_GROUPNAME_LEN + 1 + DWORDSIZE; 
+  char *data;
+  size_t data_size;
 
+  /* Allocate data. */
+  data_size = MAX(soffset + strlen(grinfo->comment) + 1, 1024);
+
+  data = SMB_MALLOC(data_size);
+  if (!data) {
+    DEBUG (1, ("Malloc fail\n"));
+    return -1;
+  }
+
   /* now send a SMBtrans command with api WGroupAdd */
   
   p = make_header(param, RAP_WGroupAdd,
@@ -253,6 +262,7 @@
       DEBUG(4,("NetGroupAdd failed\n"));
     }
   
+  SAFE_FREE(data);
   SAFE_FREE(rparam);
   SAFE_FREE(rdata);
 



More information about the samba-cvs mailing list