[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-unstable-35-g5e95c54

Volker Lendecke vl at sernet.de
Sat Oct 13 19:43:35 GMT 2007


The branch, v3-2-test has been updated
       via  5e95c548864bc8b075b8343e69a69e1a22c92456 (commit)
       via  d0f25bb89a2268c8f789dd362010f8b785489424 (commit)
       via  556c33702ce6d6c7cde43ddfe965c78ebc2963d3 (commit)
       via  76d8dedc368ecb1594780ce58ffee2a35a6f4f73 (commit)
      from  9e5ad21e6793981a01f63f2de1c4d496ade0bb54 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 5e95c548864bc8b075b8343e69a69e1a22c92456
Author: Volker Lendecke <vl at sernet.de>
Date:   Sat Oct 13 16:50:31 2007 +0200

    Use strlcpy instead of strncpy

commit d0f25bb89a2268c8f789dd362010f8b785489424
Author: Volker Lendecke <vl at sernet.de>
Date:   Sat Oct 13 16:43:07 2007 +0200

    Fix an uninitialized variable warning

commit 556c33702ce6d6c7cde43ddfe965c78ebc2963d3
Author: Volker Lendecke <vl at sernet.de>
Date:   Sat Oct 13 16:27:52 2007 +0200

    Fix a segfault with an unknown interface
    
    "interfaces = foo" with "foo" not being a known interface segfaulted for me.

commit 76d8dedc368ecb1594780ce58ffee2a35a6f4f73
Author: Volker Lendecke <vl at sernet.de>
Date:   Sat Oct 13 16:26:42 2007 +0200

    Also find loopback interfaces
    
    Not sure if a loopback interface is actually a broadcast one.

-----------------------------------------------------------------------

Summary of changes:
 source/lib/interface.c  |    8 +++++++-
 source/lib/interfaces.c |   26 +++++++++++---------------
 2 files changed, 18 insertions(+), 16 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/interface.c b/source/lib/interface.c
index 1471a06..2eaadab 100644
--- a/source/lib/interface.c
+++ b/source/lib/interface.c
@@ -460,7 +460,13 @@ static void interpret_interface(char *token)
 
 	/* maybe it is a DNS name */
 	p = strchr_m(token,'/');
-	if (!p && interpret_string_addr(&ss, token)) {
+	if (p == NULL) {
+		if (!interpret_string_addr(&ss, token)) {
+			DEBUG(2, ("interpret_interface: Can't find address "
+				  "for %s\n", token));
+			return;
+		}
+
 		for (i=0;i<total_probed;i++) {
 			if (addr_equal(&ss, &probed_ifaces[i].ip)) {
 				add_interface(&probed_ifaces[i]);
diff --git a/source/lib/interfaces.c b/source/lib/interfaces.c
index e98ea46..2b93a5b 100644
--- a/source/lib/interfaces.c
+++ b/source/lib/interfaces.c
@@ -85,6 +85,7 @@
 #endif
 
 #include "interfaces.h"
+#include "lib/replace/replace.h"
 
 /****************************************************************************
  Try the "standard" getifaddrs/freeifaddrs interfaces.
@@ -136,7 +137,7 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
 		memcpy(&ifaces[total].ip, ifptr->ifa_addr, copy_size);
 		memcpy(&ifaces[total].netmask, ifptr->ifa_netmask, copy_size);
 
-		if ((ifaces[total].flags & IFF_BROADCAST) &&
+		if ((ifaces[total].flags & (IFF_BROADCAST|IFF_LOOPBACK)) &&
 				ifptr->ifa_broadaddr) {
 			memcpy(&ifaces[total].bcast,
 				ifptr->ifa_broadaddr,
@@ -150,9 +151,8 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
 			continue;
 		}
 
-		strncpy(ifaces[total].name, ifptr->ifa_name,
-				sizeof(ifaces[total].name)-1);
-		ifaces[total].name[sizeof(ifaces[total].name)-1] = 0;
+		strlcpy(ifaces[total].name, ifptr->ifa_name,
+			sizeof(ifaces[total].name));
 		total++;
 	}
 
@@ -218,9 +218,8 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
 			continue;
 		}
 
-		strncpy(ifaces[total].name, ifr[i].ifr_name,
-				sizeof(ifaces[total].name)-1);
-		ifaces[total].name[sizeof(ifaces[total].name)-1] = 0;
+		strlcpy(ifaces[total].name, ifr[i].ifr_name,
+			sizeof(ifaces[total].name));
 
 		memcpy(&ifaces[total].ip, &ifr[i].ifr_addr,
 				sizeof(struct sockaddr_in));
@@ -331,9 +330,7 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
 			continue;
 		}
 
-		strncpy(ifaces[total].name, iname,
-				sizeof(ifaces[total].name)-1);
-		ifaces[total].name[sizeof(ifaces[total].name)-1] = 0;
+		strlcpy(ifaces[total].name, iname, sizeof(ifaces[total].name));
 
 		memcpy(&ifaces[total].ip, &ifreq.ifr_addr,
 				sizeof(struct sockaddr_in));
@@ -436,9 +433,8 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
 		memcpy(&ifaces[total].ip, &ifr->ifr_addr,
 				sizeof(struct sockaddr_in));
 
-		strncpy(ifaces[total].name, ifr->ifr_name,
-				sizeof(ifaces[total].name)-1);
-		ifaces[total].name[sizeof(ifaces[total].name)-1] = 0;
+		strlcpy(ifaces[total].name, ifr->ifr_name,
+			sizeof(ifaces[total].name));
 
 		if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) {
 			goto next;
@@ -549,10 +545,10 @@ static int iface_comp(struct iface_struct *i1, struct iface_struct *i2)
 		s1 = (struct sockaddr_in *)&i1->netmask;
 		s2 = (struct sockaddr_in *)&i2->netmask;
 
-		r = ntohl(s1->sin_addr.s_addr) -
+		return ntohl(s1->sin_addr.s_addr) -
 			ntohl(s2->sin_addr.s_addr);
 	}
-	return r;
+	return 0;
 }
 
 int get_interfaces(struct iface_struct *ifaces, int max_interfaces);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list