[Ocfs2-tools-devel] [PATCH 02/18] tunefs.ocfs2: Fix a substring bug in op_set_label.

Mark Fasheh mfasheh at suse.com
Wed Jan 14 14:37:22 PST 2009


Signed-off-by: Mark Fasheh <mfasheh at suse.com>


On Mon, Jan 05, 2009 at 06:33:38PM -0800, Joel Becker wrote:
> If tunefs was trying to set the label of a filesystem to a substring of
> the current label, it would consider the label already set, because it
> wasn't checking the string terminator.
> 
> For example, a filesystem has the label "server12".  tunefs is run with
> the label "server1" (that is, 'tunefs -L server1').  tunefs will compare
> the two strings, but only to the length of the new label.  Since the new
> label is the same as the start of the old label, tunefs says "label
> already set" and does nothing.  This is wrong.
> 
> The fix is to compare one byte more than the length of the new label.
> This includes the string terminating NUL character.
> 
> Signed-off-by: Joel Becker <joel.becker at oracle.com>
> ---
>  tunefs.ocfs2/op_set_label.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/tunefs.ocfs2/op_set_label.c b/tunefs.ocfs2/op_set_label.c
> index 7aeda91..c0a62a8 100644
> --- a/tunefs.ocfs2/op_set_label.c
> +++ b/tunefs.ocfs2/op_set_label.c
> @@ -30,7 +30,7 @@
>  static errcode_t update_volume_label(ocfs2_filesys *fs, const char *label)
>  {
>  	errcode_t err;
> -	int len = strlen(label);
> +	int len = strlen(label) + 1;  /* Compare the NUL too */
>  
>  	if (len > OCFS2_MAX_VOL_LABEL_LEN)
>  		len = OCFS2_MAX_VOL_LABEL_LEN;
> -- 
> 1.5.6.5
--
Mark Fasheh



More information about the Ocfs2-tools-devel mailing list