git.samba.org
/
ira
/
wip.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
70b416a
)
Use strlcpy instead of strncpy
author
Volker Lendecke
<vl@sernet.de>
Sat, 13 Oct 2007 14:50:31 +0000
(16:50 +0200)
committer
Volker Lendecke
<vl@sernet.de>
Sat, 13 Oct 2007 19:44:58 +0000
(21:44 +0200)
(This used to be commit
5e95c548864bc8b075b8343e69a69e1a22c92456
)
source3/lib/interfaces.c
patch
|
blob
|
history
diff --git
a/source3/lib/interfaces.c
b/source3/lib/interfaces.c
index 122101cdc996abc7131248a24ec31e2988f9849a..2b93a5ba391629533ca7c825371640cc6272082f 100644
(file)
--- a/
source3/lib/interfaces.c
+++ b/
source3/lib/interfaces.c
@@
-85,6
+85,7
@@
#endif
#include "interfaces.h"
#endif
#include "interfaces.h"
+#include "lib/replace/replace.h"
/****************************************************************************
Try the "standard" getifaddrs/freeifaddrs interfaces.
/****************************************************************************
Try the "standard" getifaddrs/freeifaddrs interfaces.
@@
-150,9
+151,8
@@
static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
continue;
}
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++;
}
total++;
}
@@
-218,9
+218,8
@@
static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
continue;
}
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));
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;
}
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));
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));
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;
if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) {
goto next;