Messages in this thread | | | Date | Fri, 28 Nov 2003 15:04:51 +0100 | From | "Ihar 'Philips' Filipau" <> | Subject | Re: [PATCH 2.6]: IPv6: strcpy -> strlcpy |
| |
Russell King wrote: > > That ends up writing uninitialised kernel data to (unprivileged) user > space. So would strcpy() used in that situation. >
I used to use:
char buf[MAX]; ... buf[MAX-1] = 0; /* zero terminate */ strncpy(buf, src, MAX-1);
This is safe regarding both 0 termination and 0 padding rest of string.
-- Ihar 'Philips' Filipau / with best regards from Saarbruecken. -- _ _ _ Because the kernel depends on it existing. "init" |_|*|_| literally _is_ special from a kernel standpoint, |_|_|*| because its' the "reaper of zombies" (and, may I add, |*|*|*| that would be a great name for a rock band). -- Linus Torvalds
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |