On Fri, Feb 20, 2015 at 01:22:15PM -0500, Russell Bryant wrote: > strncpy() has pretty annoying semantics. One bit that is odd is that > it does not guarantee that the destination string will be null > terminated. If no terminator is found in the first N bytes of the > source, it just fills the destination buffer and doesn't terminate it. > > The changes here all just subtract one from the number of characters > allowed to be copied, always leaving one last byte in the destination > to ensure that the result is null terminated. In all cases, the > source has been initialized with memset() prior to calling strncpy(). > > BSD variants provide strlcpy() which behaves more sanely in this > regard, but this change seems to be the smallest change to address the > problem. > > Signed-off-by: Russell Bryant <rbry...@redhat.com>
Thanks for the report, and the patch. All of these, and in the next patch too, can use ovs_strlcpy() instead. It's good to add a makefile rule to keep new uses from creeping over time. I sent out a pair of patches to do both of those: http://openvswitch.org/pipermail/dev/2015-February/051458.html http://openvswitch.org/pipermail/dev/2015-February/051457.html _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev