Patchwork [3/3] acpi: wmi: use snprintf to be safe

login
register
mail settings
Submitter Colin King
Date March 2, 2012, 9:10 a.m.
Message ID <1330679404-8789-4-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/144160/
State Accepted
Headers show

Comments

Colin King - March 2, 2012, 9:10 a.m.
From: Colin Ian King <colin.king@canonical.com>

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/wmi/wmi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Keng-Yu Lin - March 5, 2012, 7:54 a.m.
On Fri, Mar 2, 2012 at 5:10 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/wmi/wmi.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/src/acpi/wmi/wmi.c b/src/acpi/wmi/wmi.c
> index 8190e17..de353c6 100644
> --- a/src/acpi/wmi/wmi.c
> +++ b/src/acpi/wmi/wmi.c
> @@ -348,7 +348,7 @@ static int wmi_SSDT(fwts_framework *fw)
>
>        for (i=0; i < 16; i++) {
>                char buffer[10];
> -               sprintf(buffer,"SSDT%d", i+1);
> +               snprintf(buffer, sizeof(buffer), "SSDT%d", i+1);
>
>                ret = wmi_table(fw, "SSDT", i, buffer, &result);
>                if (ret == FWTS_NO_TABLE) {
> --
> 1.7.9
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Alex Hung - March 8, 2012, 9:48 a.m.
On 03/02/2012 05:10 PM, Colin King wrote:
> From: Colin Ian King<colin.king@canonical.com>
>
> Signed-off-by: Colin Ian King<colin.king@canonical.com>
> ---
>   src/acpi/wmi/wmi.c |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/src/acpi/wmi/wmi.c b/src/acpi/wmi/wmi.c
> index 8190e17..de353c6 100644
> --- a/src/acpi/wmi/wmi.c
> +++ b/src/acpi/wmi/wmi.c
> @@ -348,7 +348,7 @@ static int wmi_SSDT(fwts_framework *fw)
>
>   	for (i=0; i<  16; i++) {
>   		char buffer[10];
> -		sprintf(buffer,"SSDT%d", i+1);
> +		snprintf(buffer, sizeof(buffer), "SSDT%d", i+1);
>
>   		ret = wmi_table(fw, "SSDT", i, buffer,&result);
>   		if (ret == FWTS_NO_TABLE) {
Acked-by: Alex Hung <alex.hung@canonical.com>

Patch

diff --git a/src/acpi/wmi/wmi.c b/src/acpi/wmi/wmi.c
index 8190e17..de353c6 100644
--- a/src/acpi/wmi/wmi.c
+++ b/src/acpi/wmi/wmi.c
@@ -348,7 +348,7 @@  static int wmi_SSDT(fwts_framework *fw)
 
 	for (i=0; i < 16; i++) {
 		char buffer[10];
-		sprintf(buffer,"SSDT%d", i+1);
+		snprintf(buffer, sizeof(buffer), "SSDT%d", i+1);
 
 		ret = wmi_table(fw, "SSDT", i, buffer, &result);
 		if (ret == FWTS_NO_TABLE) {