User: Password:
|
|
Subscribe / Log in / New account

The ups and downs of strlcpy()

The ups and downs of strlcpy()

Posted Jul 19, 2012 15:49 UTC (Thu) by smurf (subscriber, #17840)
In reply to: The ups and downs of strlcpy() by etienne
Parent article: The ups and downs of strlcpy()

There are two easy workarounds for that:

* if you reallocate the buffer anyway, or if your program does not care about the character set, this is not a problem.

* if your program blindly assumes that its input is valid UTF-8, don't bother – you're going to fail anyway.

* otherwise, a wrapper which NULLs an incomplete UTF8 character at the end of your buffer is ten lines of C and left as an exercise to the reader. ;-)


(Log in to post comments)


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds