On Mon, Jul 04, 2011, Nicholas Marriott wrote: > Yep, you're right, the check is unnecessary, I'll remove it.
somewhere on my todo list is adding checks like these to strlcpy to catch underflow. but it makes more sense when the length is user provided. > > > On Sun, Jul 03, 2011 at 10:21:38PM -0600, Matthew Dempsky wrote: >> On Sun, Jul 3, 2011 at 10:11 PM, Nicholas Marriott >> <nicholas.marri...@gmail.com> wrote: >> > From NetBSD with overflow check and a couple of minor tweaks by me. >> > >> > libc minor bump. >> > >> > Needed for libedit with wide characters which might be nice sometime. >> > >> > Comments/ok? >> >> ok matthew@ >> >> > + ? ? ? len = wcslen(str) + 1; >> > + ? ? ? if (SIZE_MAX / sizeof (wchar_t) < len) { >> > + ? ? ? ? ? ? ? errno = ENOMEM; >> > + ? ? ? ? ? ? ? return (NULL); >> > + ? ? ? } >> >> Is this check actually necessary? How do you get a wide char string >> whose length exceeds the total address space?