Patchwork lib: fwts_uefi: fix check of empty d_name

login
register
mail settings
Submitter Colin King
Date May 6, 2013, 11:17 p.m.
Message ID <1367882273-21613-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/241828/
State Accepted
Headers show

Comments

Colin King - May 6, 2013, 11:17 p.m.
From: Colin Ian King <colin.king@canonical.com>

Coverity CID #997279, Array compared against 0 (NO_EFFECT)

Fix bug where we are comparing d_name against NULL; should
be in fact checking if first char is '\0'.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_uefi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Alex Hung - May 9, 2013, 6:18 a.m.
On 05/07/2013 07:17 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997279, Array compared against 0 (NO_EFFECT)
>
> Fix bug where we are comparing d_name against NULL; should
> be in fact checking if first char is '\0'.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_uefi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_uefi.c b/src/lib/src/fwts_uefi.c
> index 16ae1da..29cad80 100644
> --- a/src/lib/src/fwts_uefi.c
> +++ b/src/lib/src/fwts_uefi.c
> @@ -399,7 +399,7 @@ int fwts_uefi_get_variable_names(fwts_list *list)
>   		return FWTS_ERROR;
>
>   	for (i = 0; i < n; i++) {
> -		if (names[i]->d_name == NULL)
> +		if (names[i]->d_name[0] == '\0')
>   			continue;
>   		if (!strcmp(names[i]->d_name, "."))
>   			continue;
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu - May 16, 2013, 3:27 a.m.
On 05/07/2013 07:17 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997279, Array compared against 0 (NO_EFFECT)
>
> Fix bug where we are comparing d_name against NULL; should
> be in fact checking if first char is '\0'.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_uefi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_uefi.c b/src/lib/src/fwts_uefi.c
> index 16ae1da..29cad80 100644
> --- a/src/lib/src/fwts_uefi.c
> +++ b/src/lib/src/fwts_uefi.c
> @@ -399,7 +399,7 @@ int fwts_uefi_get_variable_names(fwts_list *list)
>   		return FWTS_ERROR;
>
>   	for (i = 0; i < n; i++) {
> -		if (names[i]->d_name == NULL)
> +		if (names[i]->d_name[0] == '\0')
>   			continue;
>   		if (!strcmp(names[i]->d_name, "."))
>   			continue;
>

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

Patch

diff --git a/src/lib/src/fwts_uefi.c b/src/lib/src/fwts_uefi.c
index 16ae1da..29cad80 100644
--- a/src/lib/src/fwts_uefi.c
+++ b/src/lib/src/fwts_uefi.c
@@ -399,7 +399,7 @@  int fwts_uefi_get_variable_names(fwts_list *list)
 		return FWTS_ERROR;
 
 	for (i = 0; i < n; i++) {
-		if (names[i]->d_name == NULL)
+		if (names[i]->d_name[0] == '\0')
 			continue;
 		if (!strcmp(names[i]->d_name, "."))
 			continue;