ACK: [PATCH 07/10] acpi: cstates: fix potential integer overflow
IvanHu
ivan.hu at canonical.com
Tue May 6 03:14:57 UTC 2014
On 05/01/2014 10:01 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Coverity Scan detected a potential integer overflow, this can be
> easily resolved by using the correct integer type for strtol
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
> src/acpi/cstates/cstates.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/acpi/cstates/cstates.c b/src/acpi/cstates/cstates.c
> index 9272512..e634f2d 100644
> --- a/src/acpi/cstates/cstates.c
> +++ b/src/acpi/cstates/cstates.c
> @@ -67,7 +67,7 @@ static void get_cstates(char *path, fwts_cstates *state)
>
> while ((entry = readdir(dir)) != NULL) {
> if (entry && strlen(entry->d_name)>3) {
> - int nr;
> + long int nr;
> int count;
>
> snprintf(filename, sizeof(filename), "%s/%s/name",
> @@ -81,13 +81,13 @@ static void get_cstates(char *path, fwts_cstates *state)
> * where x is the C state number.
> */
> if ((data[0] == 'C') && isdigit(data[1]))
> - nr = strtoull(data+1, NULL, 10);
> + nr = strtol(data + 1, NULL, 10);
> else if (strcmp("POLL", data) == 0)
> nr = 0;
> else {
> char *ptr = strstr(data, "-C");
> if (ptr)
> - nr = strtoull(ptr + 2, NULL, 10);
> + nr = strtol(ptr + 2, NULL, 10);
> else
> nr = 0;
> }
>
Acked-by: Ivan Hu <ivan.hu at canonical.com>
More information about the fwts-devel
mailing list