Hi and thanks for your review, On 05/08/2019 11:33, casper....@oracle.com wrote: > > >> For this reason, force both strings to use IFNAMSIZ as size and, since >> this constant may not exist on every platform, ensure it is always >> defined. > > A problem with this patch misght be that strncpy() does NOT NUL terminates the > copied string. (It writes EXACTLY IFNAMSIZ bytes but only when the string > is shorter, it will writes NUL bytes in the reminder of the char array[].)
the assumption behind this patch is that now both source and destination buffer have exactly the same size (IFNAMSIZ) and the source is NULL terminated. Therefore the problem you mentioned should not appear here, I think. > > You could use strlcpy() but I'm not sure if that is available in Windows. This code is currently used only on Linux - it is not expected to ever run on Windows. Cheers, > > >> >> /* save result in output variables */ >> memcpy(best_gw, &res.gw, res.addr_size); > - strcpy(best_iface, res.iface); >> + strncpy(best_iface, res.iface, IFNAMSIZ); > > Casper > -- Antonio Quartulli OpenVPN Inc. -- Antonio Quartulli _______________________________________________ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel