Commit b8989f93 authored by Marc Mutz's avatar Marc Mutz
Browse files

Properly null-terminate ifreq::irf_name


It's unclear whether it has to be, but there are a lot of patches floating around
on the net that indicate that Coverty requires this, and the SIOCGIFADDR micro-howto
also NUL-terminates the string.

So who is Qt to differ?

Change-Id: I1aa5a2de47a58b1d9b73556d5a6ddc48b2c40ce3
Reviewed-by: default avatarThiago Macieira <thiago.macieira@intel.com>
parent 6b6e51e5
Branches
Tags
No related merge requests found
Showing with 1 addition and 0 deletions
...@@ -165,6 +165,7 @@ static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interf ...@@ -165,6 +165,7 @@ static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interf
ifreq request; ifreq request;
strncpy(request.ifr_name, interface.toLocal8Bit().data(), sizeof(request.ifr_name)); strncpy(request.ifr_name, interface.toLocal8Bit().data(), sizeof(request.ifr_name));
request.ifr_name[sizeof(request.ifr_name) - 1] = '\0';
int result = ioctl(sock, SIOCGIFHWADDR, &request); int result = ioctl(sock, SIOCGIFHWADDR, &request);
close(sock); close(sock);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment