nmbd_namelistfb.c patch

andreas moroder claudiamoroder at st-ulrich.suedtirol.net
Sat Sep 15 05:59:11 GMT 2001


Hello,

the function add_ip_to_namerecord uses the malloc and memcpy functions to do 
what Realloc already does.

Here my small patch against 2.2.1a that uses Realloc.
The original function did NOT clean the original data when then reallocation 
failed. I did not change this behaviour.

Bye
Andreas

--- nmbd_namelistdb.c    Sat Sep 15 14:44:36 2001
+++ nmbd_namelistdb.and  Sat Sep 15 14:43:17 2001
@@ -340,7 +340,7 @@
   if( find_ip_in_name_record( namerec, new_ip ) )
     return;

-  new_list = (struct in_addr *)malloc( (namerec->data.num_ips + 1)
+  new_list = (struct in_addr *)Realloc( (char * )namerec->data.ip, 
(namerec->data.num_ips + 1)
                                        * sizeof(struct in_addr) );
   if( NULL == new_list )
   {
@@ -348,12 +348,8 @@
     return;
   }

-  memcpy( (char *)new_list,
-          (char *)namerec->data.ip,
-          namerec->data.num_ips * sizeof(struct in_addr) );
   new_list[namerec->data.num_ips] = new_ip;

-  free((char *)namerec->data.ip);
   namerec->data.ip = new_list;
   namerec->data.num_ips += 1




More information about the samba-technical mailing list