tech-security archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: strscpy



On 19.05.2020 18:00, Robert Elz wrote:
> Even with that, I still don't like overloading the result.

OK... how about the previous version of strscpy() from Linux.

static size_t strscpy(char *dest, const char *src, size_t size)
{
	size_t len = strnlen(src, size) + 1;
	if (len > size) {
		if (size)
			dest[0] = '\0';
		return 0;
	}
	memcpy(dest, src, len);
	return len;
}

https://github.com/torvalds/linux/commit/bceb7efa6a7e656bfaa67b6f54925e7db75bcd52

This one aborts on too long source. Would it match the NetBSD kernel needs?


Home | Main Index | Thread Index | Old Index