Re: [PATCH] Fix bug in parse_color that prevented the user from changing the background colors.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris Larson <clarson@xxxxxxxxxxx> wrote:

> The comments in color.c indicate that the syntax for the color options 
> in the
> git config is [fg [bg]] [attr], however the implementation fails if 
> strtol is
> unable to convert the string in its entirety into an integer.
> 
> Signed-off-by: Chris Larson <clarson@xxxxxxxxxxx>
> ---
>  color.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/color.c b/color.c
> index 7f66c29..62518fa 100644
> --- a/color.c
> +++ b/color.c
> @@ -17,7 +17,7 @@ static int parse_color(const char *name, int len)
>              return i - 1;
>      }
>      i = strtol(name, &end, 10);
> -    if (*name && !*end && i >= -1 && i <= 255)
> +    if (*name && i >= -1 && i <= 255)
>          return i;
>      return -2;
>  }

My bug, sorry. I should have tested more.

I think this new code accepts "7bold" (didn't test).  Maybe you should
do something like this instead:

	if (*name && (!*end || isspace(*end)) && i >= -1 && i <= 255)

Untested of course.  BTW, your patch is whitespace corrupted.
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux