Skip to contentSkip to conversation

: IPv6: strcpy -> strlcpy

PATCH Ihar 'Philips' Filipau 1 participant 1 message Nov 28, 2003 7 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 4 lines · Russell King

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.

Signature · 7 lines
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