mirror of
https://github.com/utmapp/edk2.git
synced 2026-12-01 14:00:40 -10:00
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=698 Within function NetRandomInitSeed(), left shift a negative value is used in: "~Time.Hour << 24" which involves undefined behavior. Since Time.Hour is of type UINT8 (range from 0 to 23), hence ~Time.Hour will be a negative value (of type int, signed). According to the C11 spec, Section 6.5.7: > 4 The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated > bits are filled with zeros. If E1 has an unsigned type, the value > of the result is E1 * 2^E2 , reduced modulo one more than the > maximum value representable in the result type. If E1 has a signed > type and nonnegative value, and E1 * 2^E2 is representable in the > result type, then that is the resulting value; otherwise, the > behavior is undefined. This commit will remove the '~' operator before 'Time.Hour', since it seems like an implementation choice for generating the seed. Cc: Steven Shi <[email protected]> Cc: Qin Long <[email protected]> Cc: Star Zeng <[email protected]> Cc: Eric Dong <[email protected]> Cc: Paolo Bonzini <[email protected]> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <[email protected]> Reviewed-by: Wu Jiaxin <[email protected]> Reviewed-by: Fu Siyuan <[email protected]> Reviewed-by: Ye Ting <[email protected]>