Patchwork fwts_acpica: fix potential null ptr dereference (LP: #1298419)

login
register
mail settings
Submitter Colin King
Date March 27, 2014, 2:30 p.m.
Message ID <1395930618-17941-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/334350/
State Accepted
Headers show

Comments

Colin King - March 27, 2014, 2:30 p.m.
From: Colin Ian King <colin.king@canonical.com>

smatch detected a potential null ptr dereference issue, we should
ensure that buffer is allocated before scan it with index().

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpica/fwts_acpica.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Alex Hung - March 31, 2014, 6:01 a.m.
On 03/27/2014 10:30 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> smatch detected a potential null ptr dereference issue, we should
> ensure that buffer is allocated before scan it with index().
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpica/fwts_acpica.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/acpica/fwts_acpica.c b/src/acpica/fwts_acpica.c
> index 9d92470..cc691c3 100644
> --- a/src/acpica/fwts_acpica.c
> +++ b/src/acpica/fwts_acpica.c
> @@ -440,7 +440,7 @@ void fwts_acpica_vprintf(const char *fmt, va_list args)
>   		}
>   	}
>
> -	if (index(buffer, '\n') != NULL) {
> +	if (buffer_len && index(buffer, '\n') != NULL) {
>   		fwts_log_info(fwts_acpica_fw, "%s", buffer);
>   		free(buffer);
>   		buffer_len = 0;
>

Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu - April 17, 2014, 3:49 a.m.
On 03/27/2014 10:30 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> smatch detected a potential null ptr dereference issue, we should
> ensure that buffer is allocated before scan it with index().
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpica/fwts_acpica.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/acpica/fwts_acpica.c b/src/acpica/fwts_acpica.c
> index 9d92470..cc691c3 100644
> --- a/src/acpica/fwts_acpica.c
> +++ b/src/acpica/fwts_acpica.c
> @@ -440,7 +440,7 @@ void fwts_acpica_vprintf(const char *fmt, va_list args)
>   		}
>   	}
>
> -	if (index(buffer, '\n') != NULL) {
> +	if (buffer_len && index(buffer, '\n') != NULL) {
>   		fwts_log_info(fwts_acpica_fw, "%s", buffer);
>   		free(buffer);
>   		buffer_len = 0;
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>

Patch

diff --git a/src/acpica/fwts_acpica.c b/src/acpica/fwts_acpica.c
index 9d92470..cc691c3 100644
--- a/src/acpica/fwts_acpica.c
+++ b/src/acpica/fwts_acpica.c
@@ -440,7 +440,7 @@  void fwts_acpica_vprintf(const char *fmt, va_list args)
 		}
 	}
 
-	if (index(buffer, '\n') != NULL) {
+	if (buffer_len && index(buffer, '\n') != NULL) {
 		fwts_log_info(fwts_acpica_fw, "%s", buffer);
 		free(buffer);
 		buffer_len = 0;