@@ -3119,14 +3119,18 @@ static int version_to_code(char *v)
for (b[i] = strtok_r(v, ".", &save_b);
b[i] != NULL;
- b[i] = strtok_r(NULL, ".", &save_b))
+ b[i] = strtok_r(NULL, ".", &save_b)) {
+ if (!is_numerical(b[i]))
+ return -EINVAL;
i++;
+ }
+ if (b[1] == NULL)
+ return KERNEL_VERSION(atoi(b[0]), 0, 0);
if (b[2] == NULL)
return KERNEL_VERSION(atoi(b[0]), atoi(b[1]), 0);
- else
- return KERNEL_VERSION(atoi(b[0]), atoi(b[1]), atoi(b[2]));
+ return KERNEL_VERSION(atoi(b[0]), atoi(b[1]), atoi(b[2]));
}
static int get_kernel_code()
As the version is now being passed by user it should be checked if its numerical. We didn't need this before as version wasn't passed by used. So this is not a bug fix. Signed-off-by: Anand Jain <anand.jain@oracle.com> --- utils.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)