Patchwork efi_runtime: memset the entire structure (LP: #1198236)

login
register
mail settings
Submitter Colin King
Date July 5, 2013, 3:44 p.m.
Message ID <1373039098-25375-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/257193/
State Accepted
Headers show

Comments

Colin King - July 5, 2013, 3:44 p.m.
From: Colin Ian King <colin.king@canonical.com>

convert_to_efi_time() is only memset'ing eft to the size of a
pointer and not the size of eft_time_t, so just the first 4 or 8
bytes (depending on the arch) are being cleared.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 efi_runtime/efi_runtime.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Alex Hung - July 8, 2013, 1:53 a.m.
On 07/05/2013 11:44 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> convert_to_efi_time() is only memset'ing eft to the size of a
> pointer and not the size of eft_time_t, so just the first 4 or 8
> bytes (depending on the arch) are being cleared.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   efi_runtime/efi_runtime.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
> index b08ce0e..7e3e949 100644
> --- a/efi_runtime/efi_runtime.c
> +++ b/efi_runtime/efi_runtime.c
> @@ -60,7 +60,7 @@ static void convert_from_efi_time(efi_time_t *eft, EFI_TIME *time)
>
>   static void convert_to_efi_time(efi_time_t *eft, EFI_TIME *time)
>   {
> -	memset(eft, 0, sizeof(eft));
> +	memset(eft, 0, sizeof(*eft));
>   	eft->year = time->Year;
>   	eft->month = time->Month;
>   	eft->day = time->Day;
>

Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu - July 11, 2013, 2:05 a.m.
On 07/05/2013 11:44 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> convert_to_efi_time() is only memset'ing eft to the size of a
> pointer and not the size of eft_time_t, so just the first 4 or 8
> bytes (depending on the arch) are being cleared.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   efi_runtime/efi_runtime.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
> index b08ce0e..7e3e949 100644
> --- a/efi_runtime/efi_runtime.c
> +++ b/efi_runtime/efi_runtime.c
> @@ -60,7 +60,7 @@ static void convert_from_efi_time(efi_time_t *eft, EFI_TIME *time)
>
>   static void convert_to_efi_time(efi_time_t *eft, EFI_TIME *time)
>   {
> -	memset(eft, 0, sizeof(eft));
> +	memset(eft, 0, sizeof(*eft));
>   	eft->year = time->Year;
>   	eft->month = time->Month;
>   	eft->day = time->Day;
>

Thanks for spotting this.
Acked-by: Ivan Hu <ivan.hu@canonical.com>

Patch

diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
index b08ce0e..7e3e949 100644
--- a/efi_runtime/efi_runtime.c
+++ b/efi_runtime/efi_runtime.c
@@ -60,7 +60,7 @@  static void convert_from_efi_time(efi_time_t *eft, EFI_TIME *time)
 
 static void convert_to_efi_time(efi_time_t *eft, EFI_TIME *time)
 {
-	memset(eft, 0, sizeof(eft));
+	memset(eft, 0, sizeof(*eft));
 	eft->year = time->Year;
 	eft->month = time->Month;
 	eft->day = time->Day;