Bug 1278504 - fixed buffer not null terminated. r=valentin
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Tue, 07 Jun 2016 15:44:11 +0300
changeset 300894 be7175764dc766594c5287ca184fc7a5c2f392d8
parent 300893 dec55e893640ed288c34e3398b3c4037fb71511d
child 300895 fdc8e838f8faeb2c8f487645d2e49ed51b157387
push id19599
push usercbook@mozilla.com
push dateWed, 08 Jun 2016 10:16:21 +0000
treeherderfx-team@81f4cc3f6f4c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1278504
milestone50.0a1
Bug 1278504 - fixed buffer not null terminated. r=valentin MozReview-Commit-ID: 4V1YcK2thiF
netwerk/base/NetworkInfoServiceCocoa.cpp
netwerk/base/NetworkInfoServiceLinux.cpp
--- a/netwerk/base/NetworkInfoServiceCocoa.cpp
+++ b/netwerk/base/NetworkInfoServiceCocoa.cpp
@@ -63,17 +63,17 @@ DoListAddresses(AddrMapType& aAddrMap)
     return NS_OK;
 }
 
 static nsresult
 ListInterfaceAddresses(int aFd, const char* aInterface, AddrMapType& aAddrMap)
 {
     struct ifreq ifreq;
     memset(&ifreq, 0, sizeof(struct ifreq));
-    strncpy(ifreq.ifr_name, aInterface, IFNAMSIZ);
+    strncpy(ifreq.ifr_name, aInterface, IFNAMSIZ - 1);
     if (ioctl(aFd, SIOCGIFADDR, &ifreq) != 0) {
         return NS_ERROR_FAILURE;
     }
 
     char host[128];
     int family;
     switch(family=ifreq.ifr_addr.sa_family) {
       case AF_INET:
--- a/netwerk/base/NetworkInfoServiceLinux.cpp
+++ b/netwerk/base/NetworkInfoServiceLinux.cpp
@@ -63,17 +63,17 @@ DoListAddresses(AddrMapType& aAddrMap)
     return NS_OK;
 }
 
 static nsresult
 ListInterfaceAddresses(int aFd, const char* aInterface, AddrMapType& aAddrMap)
 {
     struct ifreq ifreq;
     memset(&ifreq, 0, sizeof(struct ifreq));
-    strncpy(ifreq.ifr_name, aInterface, IFNAMSIZ);
+    strncpy(ifreq.ifr_name, aInterface, IFNAMSIZ - 1);
     if (ioctl(aFd, SIOCGIFADDR, &ifreq) != 0) {
         return NS_ERROR_FAILURE;
     }
 
     char host[128];
     int family;
     switch(family=ifreq.ifr_addr.sa_family) {
       case AF_INET: