On Sep 24, 2014, at 12:11 PM, Scott Duplichan <[email protected]> wrote:

> Hello Jaben, Shumin or someone else,
>  
> Please help me understand this one line patch. How can the original code 
> dereference a null pointer? For both Mv.c and Cp.c, the code that calls 
> ShellLevel2StripQuotes() checks the return status before attempting to 
> dereference the pointer returned by the function. If ShellLevel2StripQuotes() 
> returns error, Mv.c and Cp.c both return an error to their caller _before_ 
> any attempt to dereference the returned pointer. The function 
> ShellLevel2StripQuotes() returns an error status for all cases where it 
> returns a null pointer. What am I missing?
>  
> Also, is ASSERT guaranteed to stop execution for all build types and all 
> values of PcdDebugPropertyMask? If so, is stopping execution a suitable error 
> handling response for release code?
>  

If the platform is not defining MDEPKG_NDEBUG then the PcdDebugPropertyMask is 
in control of what happens on an ASSERT. So it is configurable, and some builds 
could have it turned off.


https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Include/Library/DebugLib.h

/**  
  Macro that calls DebugAssert() if an expression evaluates to FALSE.

  If MDEPKG_NDEBUG is not defined and the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED 
  bit of PcdDebugProperyMask is set, then this macro evaluates the Boolean 
  expression specified by Expression.  If Expression evaluates to FALSE, then 
  DebugAssert() is called passing in the source filename, source line number, 
  and Expression.

  @param  Expression  Boolean expression.

**/
#if !defined(MDEPKG_NDEBUG)       
  #define ASSERT(Expression)        \
    do {                            \
      if (DebugAssertEnabled ()) {  \
        if (!(Expression)) {        \
          _ASSERT (Expression);     \
        }                           \
      }                             \
    } while (FALSE)
#else
  #define ASSERT(Expression)
#endif
https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c
/**
  Returns TRUE if ASSERT() macros are enabled.

  This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of 
  PcdDebugProperyMask is set.  Otherwise FALSE is returned.

  @retval  TRUE    The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of 
PcdDebugProperyMask is set.
  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of 
PcdDebugProperyMask is clear.

**/
BOOLEAN
EFIAPI
DebugAssertEnabled (
  VOID
  )
{
  return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & 
DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
}
Thanks,

Andrew Fish


> Thanks,
> Scott
>  
> From: Carsey, Jaben [mailto:[email protected]] 
> Sent: Wednesday, September 24, 2014 12:12 PM
> To: Qiu, Shumin
> Cc: [email protected]
> Subject: Re: [edk2] [Patch] ShellPkg: Refine code style to avoid potential 
> NullPointer dereference.
>  
> Reviewed-by: Jaben Carsey <[email protected]>
>  
> From: Qiu, Shumin 
> Sent: Monday, September 22, 2014 8:03 PM
> To: Carsey, Jaben
> Cc: [email protected]
> Subject: [edk2] [Patch] ShellPkg: Refine code style to avoid potential 
> NullPointer dereference.
> Importance: High
>  
> Hi Jaben,
> Could you help review the patch? Pointer ‘CleanFilePathStr’ returned from 
> function ‘ShellLevel2StripQuotes’ may be NULL and may be dereferenced.
>  
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Qiu Shumin <[email protected]>
>  
> Thanks,
> Shumin
>  
> ------------------------------------------------------------------------------
> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk_______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to