3 ms·
The API of strcpy() is unsafe by design. The only way to make it safe is to not use it, and it's not musl's (nor glibc's) fault that this is the case. musl is
by cyphar 7y ago
The API of strcpy() is unsafe by design. The only way to make it safe is to not use it, and it's not musl's (nor glibc's) fault that this is the case.
musl is interesting for a variety of other reasons, but being more memory safe isn't really one of them.
- _kst_ 7y agostrpy() is safe when used safely. That means that you've confirmed that the target is big enough. For example, there's no way this can fail: char s[10]; strcpy(s, "hello"); The problem is that it can also be used unsafely, and except in the simplest cases it's difficult or impossible to tell whether a give usage is safe. By contrast, gets() (which isn't even in the language anymore) is inherently unsafe, because you can't control what will appear on standard input.