[Crash-utility] [PATCH] Parse two number kernel versions i.e. 3.8
Dave Anderson
anderson at redhat.com
Thu Aug 1 20:33:33 UTC 2013
----- Original Message -----
> Hello Dave,
>
> A Debian user, Timo Juhani Lindfors <timo.lindfors at iki.fi>, 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 at redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility
>
More information about the Crash-utility
mailing list