Re: [PATCH] Parse two number kernel versions i.e. 3.8

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

 




----- Original Message -----
> Hello Dave,
> 
> A Debian user, Timo Juhani Lindfors <timo.lindfors@xxxxxx>, reported
> this issue that and delivered the patch to resolve it. The original
> strcpy is being called with overlapping arguments because it is
> expecting an additional version number.
> 
> Troy

Looks good to me -- I don't have a 2-digit kernel to test it with,
but it still works fine for 3-digits.  Queued for crash-7.0.2.

Thanks,
  Dave

> 
> ---
> diff -urpN -urN ori/kernel.c new/kernel.c
> --- ori/kernel.c	2013-08-01 11:40:01.299157220 -0600
> +++ new/kernel.c	2013-08-01 11:42:12.506364789 -0600
> @@ -218,21 +218,29 @@ kernel_init()
>  
>  	strncpy(buf, kt->utsname.release, MIN(strlen(kt->utsname.release), 65));
>  	if (ascii_string(kt->utsname.release)) {
> +		char separator;
> +
>  		p1 = p2 = buf;
>  		while (*p2 != '.')
>  			p2++;
>  		*p2 = NULLCHAR;
>  		kt->kernel_version[0] = atoi(p1);
>  		p1 = ++p2;
> -		while (*p2 != '.')
> +		while (*p2 != '.' && *p2 != '-' && *p2 != '\0')
>  			p2++;
> +		separator = *p2;
>  		*p2 = NULLCHAR;
>  		kt->kernel_version[1] = atoi(p1);
> -		p1 = ++p2;
> -		while ((*p2 >= '0') && (*p2 <= '9'))
> -			p2++;
> -		*p2 = NULLCHAR;
> -		kt->kernel_version[2] = atoi(p1);
> +		*p2 = separator;
> +		if (*p2 == '.') {
> +			p1 = ++p2;
> +			while ((*p2 >= '0') && (*p2 <= '9'))
> +				p2++;
> +			*p2 = NULLCHAR;
> +			kt->kernel_version[2] = atoi(p1);
> +		} else {
> +			kt->kernel_version[2] = 0;
> +		}
>  
>  		if (CRASHDEBUG(1))
>  			fprintf(fp, "base kernel version: %d.%d.%d\n",
> 
> --
> Crash-utility mailing list
> Crash-utility@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/crash-utility
> 

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux