qnetworkinterface_unix: Use qstrncpy instead of strlcpy
strlcpy is not available on some UNIX platforms, such as GNU/kFreeBSD. qstrncpy is available everywhere and has similar semantics (in addition it fills the rest of buffer size with NULL bytes, but that does not cause extra work as our buffer sizes are small). Change-Id: I76c5905eba248fd9fbc1f63f05e88e0617f8407a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
4538dd7ec4
commit
d0fadae79f
@ -38,6 +38,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qbytearray.h"
|
||||
#include "qset.h"
|
||||
#include "qnetworkinterface.h"
|
||||
#include "qnetworkinterface_p.h"
|
||||
@ -500,7 +501,7 @@ static QList<QNetworkInterfacePrivate *> createInterfaces(ifaddrs *rawList)
|
||||
iface->flags = convertFlags(ptr->ifa_flags);
|
||||
iface->hardwareAddress = iface->makeHwAddress(sdl->sdl_alen, (uchar*)LLADDR(sdl));
|
||||
|
||||
strlcpy(mediareq.ifm_name, ptr->ifa_name, sizeof(mediareq.ifm_name));
|
||||
qstrncpy(mediareq.ifm_name, ptr->ifa_name, sizeof(mediareq.ifm_name));
|
||||
iface->type = probeIfType(openSocket(socket), sdl->sdl_type, &mediareq);
|
||||
iface->mtu = getMtu(socket, &req);
|
||||
}
|
||||
@ -524,7 +525,7 @@ static void getAddressExtraInfo(QNetworkAddressEntry *entry, struct sockaddr *sa
|
||||
return;
|
||||
}
|
||||
|
||||
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
qstrncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
|
||||
// get flags
|
||||
ifr.ifr_addr = *reinterpret_cast<struct sockaddr_in6 *>(sa);
|
||||
|
Loading…
x
Reference in New Issue
Block a user