Patchwork uefi: uefidump: missing va_end on str == NULL return path

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

Comments

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

Coverity CID #997322, Missing varargs init or cleanup (VARARGS)

Coverity detected a missing va_end on the str == NULL error
return path.  Fix this by using va_end() immediately after we
finish using args.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/uefi/uefidump/uefidump.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Alex Hung - May 10, 2013, 12:52 a.m.
On 05/07/2013 07:56 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997322, Missing varargs init or cleanup (VARARGS)
>
> Coverity detected a missing va_end on the str == NULL error
> return path.  Fix this by using va_end() immediately after we
> finish using args.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/uefi/uefidump/uefidump.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index 771f904..fa914ba 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -60,8 +60,8 @@ static char *uefidump_vprintf(char *str, const char *fmt, ...)
>   	char buffer[4096];
>
>   	va_start(args, fmt);
> -
>   	vsnprintf(buffer, sizeof(buffer), fmt, args);
> +	va_end(args);
>
>   	if (str == NULL)
>   		str = strdup(buffer);
> @@ -72,7 +72,6 @@ static char *uefidump_vprintf(char *str, const char *fmt, ...)
>   		strcat(str, buffer);
>   	}
>
> -	va_end(args);
>   	return str;
>   }
>
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu - May 16, 2013, 3:47 a.m.
On 05/07/2013 07:56 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997322, Missing varargs init or cleanup (VARARGS)
>
> Coverity detected a missing va_end on the str == NULL error
> return path.  Fix this by using va_end() immediately after we
> finish using args.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/uefi/uefidump/uefidump.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index 771f904..fa914ba 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -60,8 +60,8 @@ static char *uefidump_vprintf(char *str, const char *fmt, ...)
>   	char buffer[4096];
>
>   	va_start(args, fmt);
> -
>   	vsnprintf(buffer, sizeof(buffer), fmt, args);
> +	va_end(args);
>
>   	if (str == NULL)
>   		str = strdup(buffer);
> @@ -72,7 +72,6 @@ static char *uefidump_vprintf(char *str, const char *fmt, ...)
>   		strcat(str, buffer);
>   	}
>
> -	va_end(args);
>   	return str;
>   }
>
>

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

Patch

diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
index 771f904..fa914ba 100644
--- a/src/uefi/uefidump/uefidump.c
+++ b/src/uefi/uefidump/uefidump.c
@@ -60,8 +60,8 @@  static char *uefidump_vprintf(char *str, const char *fmt, ...)
 	char buffer[4096];
 
 	va_start(args, fmt);
-
 	vsnprintf(buffer, sizeof(buffer), fmt, args);
+	va_end(args);
 
 	if (str == NULL)
 		str = strdup(buffer);
@@ -72,7 +72,6 @@  static char *uefidump_vprintf(char *str, const char *fmt, ...)
 		strcat(str, buffer);
 	}
 
-	va_end(args);
 	return str;
 }