public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [patch] MdeModulePkg/BMMUiLib: Remove old useless data before new save action
@ 2017-02-20  5:05 Dandan Bi
  2017-02-20  5:05 ` [patch] MdeModulePkg/HiiDatabase: clean the value before setting default string Dandan Bi
  2017-02-20 11:13 ` [patch] MdeModulePkg/BMMUiLib: Remove old useless data before new save action Dong, Eric
  0 siblings, 2 replies; 4+ messages in thread
From: Dandan Bi @ 2017-02-20  5:05 UTC (permalink / raw)
  To: edk2-devel; +Cc: Eric Dong, Liming Gao

There exits the case that when saving changes in form A,
the old saved data in form B are not cleaned, will be saved
again with the new save. Thus incorrect UI behavior will be
shown. This patch is to remove some useless data.

https://bugzilla.tianocore.org/show_bug.cgi?id=385

Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 .../BootMaintenanceManagerUiLib/BootMaintenance.c  | 35 +++++++++++++++++++++-
 .../BootMaintenanceManager.h                       | 14 ++++++++-
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
index e49ab98..3ff23a5 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
@@ -1,9 +1,9 @@
 /** @file
 The functions for Boot Maintainence Main menu.
 
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -1212,13 +1212,15 @@ BootMaintCallback (
     if ((Value == NULL) || (ActionRequest == NULL)) {
       return EFI_INVALID_PARAMETER;
     }
    
     if (QuestionId == KEY_VALUE_SAVE_AND_EXIT_BOOT) {
+      CleanUselessBeforeSubmit (Private);
       CurrentFakeNVMap->BootOptionChanged = FALSE;
       *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
     } else if (QuestionId == KEY_VALUE_SAVE_AND_EXIT_DRIVER) {
+      CleanUselessBeforeSubmit (Private);
       CurrentFakeNVMap->DriverOptionChanged = FALSE;
       *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
     } else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT_DRIVER) {
       //
       // Discard changes and exit formset
@@ -1267,10 +1269,11 @@ BootMaintCallback (
     } else {
       switch (QuestionId) {
       case KEY_VALUE_SAVE_AND_EXIT:
       case KEY_VALUE_NO_SAVE_AND_EXIT:
         if (QuestionId == KEY_VALUE_SAVE_AND_EXIT) {
+          CleanUselessBeforeSubmit (Private);
           *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
         } else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT) {
           DiscardChangeHandler (Private, CurrentFakeNVMap);
           *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
         }
@@ -1369,10 +1372,40 @@ DiscardChangeHandler (
     break;
   }
 }
 
 /**
+  This function is to clean some useless data before submit changes.
+
+  @param Private            The BMM context data.
+
+**/
+VOID
+CleanUselessBeforeSubmit (
+  IN  BMM_CALLBACK_DATA               *Private
+  )
+{
+  UINT16  Index;
+  if (Private->BmmPreviousPageId != FORM_BOOT_DEL_ID) {
+    for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {
+      if (Private->BmmFakeNvData.BootOptionDel[Index] && !Private->BmmFakeNvData.BootOptionDelMark[Index]) {
+        Private->BmmFakeNvData.BootOptionDel[Index] = FALSE;
+        Private->BmmOldFakeNVData.BootOptionDel[Index] = FALSE;
+      }
+    }
+  }
+  if (Private->BmmPreviousPageId != FORM_DRV_DEL_ID) {
+    for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {
+      if (Private->BmmFakeNvData.DriverOptionDel[Index] && !Private->BmmFakeNvData.DriverOptionDelMark[Index]) {
+        Private->BmmFakeNvData.DriverOptionDel[Index] = FALSE;
+        Private->BmmOldFakeNVData.DriverOptionDel[Index] = FALSE;
+      }
+    }
+  }
+}
+
+/**
 
   Update the menus in the BMM page.
 
 **/
 VOID
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h
index 0665c78..532b75b 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h
@@ -1,9 +1,9 @@
 /** @file
 Header file for boot maintenance module.
 
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -1047,10 +1047,22 @@ VOID
 DiscardChangeHandler (
   IN  BMM_CALLBACK_DATA               *Private,
   IN  BMM_FAKE_NV_DATA                *CurrentFakeNVMap
   );
 
+
+/**
+  This function is to clean some useless data before submit changes.
+
+  @param Private            The BMM context data.
+
+**/
+VOID
+CleanUselessBeforeSubmit (
+  IN  BMM_CALLBACK_DATA               *Private
+  );
+
 /**
   Dispatch the display to the next page based on NewPageId.
 
   @param Private         The BMM context data.
   @param NewPageId       The original page ID.
-- 
1.9.5.msysgit.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [patch] MdeModulePkg/HiiDatabase: clean the value before setting default string
  2017-02-20  5:05 [patch] MdeModulePkg/BMMUiLib: Remove old useless data before new save action Dandan Bi
@ 2017-02-20  5:05 ` Dandan Bi
  2017-02-20 11:13   ` Dong, Eric
  2017-02-20 11:13 ` [patch] MdeModulePkg/BMMUiLib: Remove old useless data before new save action Dong, Eric
  1 sibling, 1 reply; 4+ messages in thread
From: Dandan Bi @ 2017-02-20  5:05 UTC (permalink / raw)
  To: edk2-devel; +Cc: Eric Dong, Liming Gao

For string op-code, the default string may not exceed the
maximum size, so when generating <AltResp> string, we should
clean the value before setting the default string.

https://bugzilla.tianocore.org/show_bug.cgi?id=375

Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
index d547f42..1878106 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
@@ -1,9 +1,9 @@
 /** @file
 Implementation of interfaces function for EFI_HII_CONFIG_ROUTING_PROTOCOL.
 
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -3696,21 +3696,29 @@ GenerateAltConfigResp (
         // Convert Value to a hex string in "%x" format
         // NOTE: This is in the opposite byte that GUID and PATH use
         //
         if (BlockData->OpCode == EFI_IFR_STRING_OP){
           DefaultString   = InternalGetString(HiiHandle, DefaultValueData->Value.string);
-          TmpBuffer = (UINT8 *) DefaultString;
+          TmpBuffer = AllocateZeroPool (Width);
+          ASSERT (TmpBuffer != NULL);
+          if (DefaultString != NULL) {
+            CopyMem (TmpBuffer, (UINT8 *) DefaultString, StrLen(DefaultString)* sizeof (CHAR16));
+          }
         } else {
           TmpBuffer = (UINT8 *) &(DefaultValueData->Value);
         }
         for (; Width > 0 && (TmpBuffer != NULL); Width--) {
           StringPtr += UnicodeValueToString (StringPtr, PREFIX_ZERO | RADIX_HEX, TmpBuffer[Width - 1], 2);
         }
         if (DefaultString != NULL){
           FreePool(DefaultString);
           DefaultString = NULL;
         }
+        if (BlockData->OpCode == EFI_IFR_STRING_OP && TmpBuffer != NULL) {
+          FreePool(TmpBuffer);
+          TmpBuffer  = NULL;
+        }
       }
     }
   }
 
   HiiToLower (*DefaultAltCfgResp);
-- 
1.9.5.msysgit.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch] MdeModulePkg/HiiDatabase: clean the value before setting default string
  2017-02-20  5:05 ` [patch] MdeModulePkg/HiiDatabase: clean the value before setting default string Dandan Bi
@ 2017-02-20 11:13   ` Dong, Eric
  0 siblings, 0 replies; 4+ messages in thread
From: Dong, Eric @ 2017-02-20 11:13 UTC (permalink / raw)
  To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Gao, Liming

Dandan,

You need to also add check to avoid string size exceed the width.

Thanks,
Eric

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Dandan Bi
> Sent: Monday, February 20, 2017 1:06 PM
> To: edk2-devel@lists.01.org
> Cc: Dong, Eric; Gao, Liming
> Subject: [edk2] [patch] MdeModulePkg/HiiDatabase: clean the value before setting default string
> 
> For string op-code, the default string may not exceed the
> maximum size, so when generating <AltResp> string, we should
> clean the value before setting the default string.
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=375
> 
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Dandan Bi <dandan.bi@intel.com>
> ---
>  MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> index d547f42..1878106 100644
> --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
> @@ -1,9 +1,9 @@
>  /** @file
>  Implementation of interfaces function for EFI_HII_CONFIG_ROUTING_PROTOCOL.
> 
> -Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD License
>  which accompanies this distribution.  The full text of the license may be found at
>  http://opensource.org/licenses/bsd-license.php
> 
> @@ -3696,21 +3696,29 @@ GenerateAltConfigResp (
>          // Convert Value to a hex string in "%x" format
>          // NOTE: This is in the opposite byte that GUID and PATH use
>          //
>          if (BlockData->OpCode == EFI_IFR_STRING_OP){
>            DefaultString   = InternalGetString(HiiHandle, DefaultValueData->Value.string);
> -          TmpBuffer = (UINT8 *) DefaultString;
> +          TmpBuffer = AllocateZeroPool (Width);
> +          ASSERT (TmpBuffer != NULL);
> +          if (DefaultString != NULL) {
> +            CopyMem (TmpBuffer, (UINT8 *) DefaultString, StrLen(DefaultString)* sizeof (CHAR16));
> +          }
>          } else {
>            TmpBuffer = (UINT8 *) &(DefaultValueData->Value);
>          }
>          for (; Width > 0 && (TmpBuffer != NULL); Width--) {
>            StringPtr += UnicodeValueToString (StringPtr, PREFIX_ZERO | RADIX_HEX, TmpBuffer[Width - 1], 2);
>          }
>          if (DefaultString != NULL){
>            FreePool(DefaultString);
>            DefaultString = NULL;
>          }
> +        if (BlockData->OpCode == EFI_IFR_STRING_OP && TmpBuffer != NULL) {
> +          FreePool(TmpBuffer);
> +          TmpBuffer  = NULL;
> +        }
>        }
>      }
>    }
> 
>    HiiToLower (*DefaultAltCfgResp);
> --
> 1.9.5.msysgit.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] MdeModulePkg/BMMUiLib: Remove old useless data before new save action
  2017-02-20  5:05 [patch] MdeModulePkg/BMMUiLib: Remove old useless data before new save action Dandan Bi
  2017-02-20  5:05 ` [patch] MdeModulePkg/HiiDatabase: clean the value before setting default string Dandan Bi
@ 2017-02-20 11:13 ` Dong, Eric
  1 sibling, 0 replies; 4+ messages in thread
From: Dong, Eric @ 2017-02-20 11:13 UTC (permalink / raw)
  To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Gao, Liming

Reviewed-by: Eric Dong <eric.dong@intel.com>

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Dandan Bi
> Sent: Monday, February 20, 2017 1:06 PM
> To: edk2-devel@lists.01.org
> Cc: Dong, Eric; Gao, Liming
> Subject: [edk2] [patch] MdeModulePkg/BMMUiLib: Remove old useless data before new save action
> 
> There exits the case that when saving changes in form A,
> the old saved data in form B are not cleaned, will be saved
> again with the new save. Thus incorrect UI behavior will be
> shown. This patch is to remove some useless data.
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=385
> 
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Dandan Bi <dandan.bi@intel.com>
> ---
>  .../BootMaintenanceManagerUiLib/BootMaintenance.c  | 35 +++++++++++++++++++++-
>  .../BootMaintenanceManager.h                       | 14 ++++++++-
>  2 files changed, 47 insertions(+), 2 deletions(-)
> 
> diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
> b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
> index e49ab98..3ff23a5 100644
> --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
> +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
> @@ -1,9 +1,9 @@
>  /** @file
>  The functions for Boot Maintainence Main menu.
> 
> -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD License
>  which accompanies this distribution.  The full text of the license may be found at
>  http://opensource.org/licenses/bsd-license.php
> 
> @@ -1212,13 +1212,15 @@ BootMaintCallback (
>      if ((Value == NULL) || (ActionRequest == NULL)) {
>        return EFI_INVALID_PARAMETER;
>      }
> 
>      if (QuestionId == KEY_VALUE_SAVE_AND_EXIT_BOOT) {
> +      CleanUselessBeforeSubmit (Private);
>        CurrentFakeNVMap->BootOptionChanged = FALSE;
>        *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
>      } else if (QuestionId == KEY_VALUE_SAVE_AND_EXIT_DRIVER) {
> +      CleanUselessBeforeSubmit (Private);
>        CurrentFakeNVMap->DriverOptionChanged = FALSE;
>        *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
>      } else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT_DRIVER) {
>        //
>        // Discard changes and exit formset
> @@ -1267,10 +1269,11 @@ BootMaintCallback (
>      } else {
>        switch (QuestionId) {
>        case KEY_VALUE_SAVE_AND_EXIT:
>        case KEY_VALUE_NO_SAVE_AND_EXIT:
>          if (QuestionId == KEY_VALUE_SAVE_AND_EXIT) {
> +          CleanUselessBeforeSubmit (Private);
>            *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
>          } else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT) {
>            DiscardChangeHandler (Private, CurrentFakeNVMap);
>            *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
>          }
> @@ -1369,10 +1372,40 @@ DiscardChangeHandler (
>      break;
>    }
>  }
> 
>  /**
> +  This function is to clean some useless data before submit changes.
> +
> +  @param Private            The BMM context data.
> +
> +**/
> +VOID
> +CleanUselessBeforeSubmit (
> +  IN  BMM_CALLBACK_DATA               *Private
> +  )
> +{
> +  UINT16  Index;
> +  if (Private->BmmPreviousPageId != FORM_BOOT_DEL_ID) {
> +    for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {
> +      if (Private->BmmFakeNvData.BootOptionDel[Index] && !Private->BmmFakeNvData.BootOptionDelMark[Index]) {
> +        Private->BmmFakeNvData.BootOptionDel[Index] = FALSE;
> +        Private->BmmOldFakeNVData.BootOptionDel[Index] = FALSE;
> +      }
> +    }
> +  }
> +  if (Private->BmmPreviousPageId != FORM_DRV_DEL_ID) {
> +    for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {
> +      if (Private->BmmFakeNvData.DriverOptionDel[Index] && !Private->BmmFakeNvData.DriverOptionDelMark[Index]) {
> +        Private->BmmFakeNvData.DriverOptionDel[Index] = FALSE;
> +        Private->BmmOldFakeNVData.DriverOptionDel[Index] = FALSE;
> +      }
> +    }
> +  }
> +}
> +
> +/**
> 
>    Update the menus in the BMM page.
> 
>  **/
>  VOID
> diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h
> b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h
> index 0665c78..532b75b 100644
> --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h
> +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h
> @@ -1,9 +1,9 @@
>  /** @file
>  Header file for boot maintenance module.
> 
> -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD License
>  which accompanies this distribution.  The full text of the license may be found at
>  http://opensource.org/licenses/bsd-license.php
> 
> @@ -1047,10 +1047,22 @@ VOID
>  DiscardChangeHandler (
>    IN  BMM_CALLBACK_DATA               *Private,
>    IN  BMM_FAKE_NV_DATA                *CurrentFakeNVMap
>    );
> 
> +
> +/**
> +  This function is to clean some useless data before submit changes.
> +
> +  @param Private            The BMM context data.
> +
> +**/
> +VOID
> +CleanUselessBeforeSubmit (
> +  IN  BMM_CALLBACK_DATA               *Private
> +  );
> +
>  /**
>    Dispatch the display to the next page based on NewPageId.
> 
>    @param Private         The BMM context data.
>    @param NewPageId       The original page ID.
> --
> 1.9.5.msysgit.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-02-20 11:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-20  5:05 [patch] MdeModulePkg/BMMUiLib: Remove old useless data before new save action Dandan Bi
2017-02-20  5:05 ` [patch] MdeModulePkg/HiiDatabase: clean the value before setting default string Dandan Bi
2017-02-20 11:13   ` Dong, Eric
2017-02-20 11:13 ` [patch] MdeModulePkg/BMMUiLib: Remove old useless data before new save action Dong, Eric

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox