Start to add truncate checks on all uses of strlcpy(). Reading lwn
[sfrench/samba-autobuild/.git] / lib / socket / interfaces.c
index 775956ba990c4f36c4db744b99f64a599fd2df01..74c642372a24323befae23534d1f525991a96fab 100644 (file)
@@ -212,8 +212,12 @@ static int _get_interfaces(TALLOC_CTX *mem_ctx, struct iface_struct **pifaces)
                        continue;
                }
 
-               strlcpy(ifaces[total].name, ifptr->ifa_name,
-                       sizeof(ifaces[total].name));
+               if (strlcpy(ifaces[total].name, ifptr->ifa_name,
+                       sizeof(ifaces[total].name)) >=
+                               sizeof(ifaces[total].name)) {
+                       /* Truncation ! Ignore. */
+                       continue;
+               }
                total++;
        }