Re: [PATCH] Btrfs-progs use safe string manipulation functions

2011-02-11 Thread Lars Wirzenius
On to, 2011-02-10 at 10:29 -0300, Eduardo Silva wrote: [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

Re: [PATCH] Btrfs-progs use safe string manipulation functions

2011-02-10 Thread Olaf van der Spek
On Thu, Feb 10, 2011 at 12:37 PM, Jeremy Sanders jer...@jeremysanders.net wrote: Olaf van der Spek wrote: On Thu, Feb 10, 2011 at 12:08 PM, Thomas Bellman bell...@nsc.liu.se wrote: strncpy(args.name, source, BTRFS_PATH_NAME_MAX); args.name[BTRFS_PATH_NAME_MAX] = '\0'; That's silly. Isn't

Re: [PATCH] Btrfs-progs use safe string manipulation functions

2011-02-10 Thread Lars Wirzenius
On to, 2011-02-10 at 11:37 +, Jeremy Sanders wrote: There's strlcpy, but it's not in glibc because of possible truncation errors! snprintf is standard, and should be about as safe as it gets with the glibc functions. -- To unsubscribe from this list: send the line unsubscribe linux-btrfs

Re: [PATCH] Btrfs-progs use safe string manipulation functions

2011-02-10 Thread Olaf van der Spek
On Thu, Feb 10, 2011 at 12:54 PM, Lars Wirzenius l...@liw.fi wrote: On to, 2011-02-10 at 11:37 +, Jeremy Sanders wrote: There's strlcpy, but it's not in glibc because of possible truncation errors! snprintf is standard, and should be about as safe as it gets with the glibc functions.

Re: [PATCH] Btrfs-progs use safe string manipulation functions

2011-02-10 Thread Thomas Bellman
On 2011-02-10 13:27, Olaf van der Spek wrote: On Thu, Feb 10, 2011 at 12:54 PM, Lars Wirzenius l...@liw.fi wrote: snprintf is standard, and should be about as safe as it gets with the glibc functions. But snprintf is not like strlcpy. It is indeed uglier to write 'snprintf(dst, size, %s,

Re: [PATCH] Btrfs-progs use safe string manipulation functions

2011-02-10 Thread Eduardo Silva
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 jer...@jeremysanders.net wrote: Olaf van der Spek wrote: On Thu, Feb 10, 2011 at 12:08 PM, Thomas Bellman bell...@nsc.liu.se wrote: strncpy(args.name, source,

Re: [PATCH] Btrfs-progs use safe string manipulation functions

2011-02-10 Thread Olaf van der Spek
On Thu, Feb 10, 2011 at 12:37 PM, Jeremy Sanders jer...@jeremysanders.net wrote: Of course C++ strings would be much better... :-) Yeah, why isn't C++ being used? Olaf -- To unsubscribe from this list: send the line unsubscribe linux-btrfs in the body of a message to majord...@vger.kernel.org

Re: [PATCH] Btrfs-progs use safe string manipulation functions

2011-02-10 Thread Goffredo Baroncelli
On 02/10/2011 02:29 PM, Eduardo Silva wrote: 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 jer...@jeremysanders.net wrote: Olaf van der Spek wrote: On Thu, Feb 10, 2011 at 12:08 PM, Thomas Bellman bell...@nsc.liu.se wrote:

Re: [PATCH] Btrfs-progs use safe string manipulation functions

2011-02-07 Thread Goffredo Baroncelli
On 02/07/2011 01:22 PM, Eduardo Silva wrote: Please find the attached patch which replace unsafe strcpy(3) by strncpy(3) functions. regards, Eduardo Silva Hi Eduardo, even though some strncpy are unneeded because a check is performed before, I fully agree that strncpy is better than a