On Thu, 2011-02-10 at 12:39 +0100, Olaf van der Spek wrote:
On Thu, Feb 10, 2011 at 12:37 PM, Jeremy Sanders
[off-list ref] wrote:
quoted
Olaf van der Spek wrote:
quoted
On Thu, Feb 10, 2011 at 12:08 PM, Thomas Bellman [off-list ref]
wrote:
quoted
strncpy(args.name, source, BTRFS_PATH_NAME_MAX);
args.name[BTRFS_PATH_NAME_MAX] = '\0';
That's silly. Isn't there a sane safe variant of strcpy?
There's strlcpy, but it's not in glibc because of possible truncation
errors!
Then use a private wrapper.
Here's the new patch:
----
[PATCH] Add safe string manipulation functions
Deprecate direct use of strcpy(3)
The following string manipulation function has been added:
- string_copy() : wrapper of strcpy(3)
- string_ncopy(): wrapper of strncpy(3)
both function compose safe NULL terminated strings.
----
I check that the code most of the time raise an error if the path is too
long, so the new wrappers should be ok...
best,
Eduardo Silva