Fix gcc 8 string-op-truncation warning

Don't use the full size of dest in strncpy, we override the last byte
anyway afterwards.

Change-Id: I9f1618cc9019e0060f01deed58a726caa1989d3f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Allan Sandfeld Jensen 2018-01-16 15:20:07 +01:00
parent 8072c36eeb
commit 0ed471419a

View File

@ -132,7 +132,7 @@ static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interf
int sock = socket(AF_INET, SOCK_DGRAM, 0);
ifreq request;
strncpy(request.ifr_name, interface.toLocal8Bit().data(), sizeof(request.ifr_name));
strncpy(request.ifr_name, interface.toLocal8Bit().data(), sizeof(request.ifr_name) - 1);
request.ifr_name[sizeof(request.ifr_name) - 1] = '\0';
int result = ioctl(sock, SIOCGIFHWADDR, &request);
close(sock);