oss-sec mailing list archives

Re: Interesting behavior with struct initiailization


From: Bhadrinath <bitstrat () gmail com>
Date: Sun, 5 Dec 2010 20:52:46 +0000 (UTC)

There was a specific concern in the previous posts.

"Even if the memset is not removed, a compiler could implement 'x.b = 2' by
-setting the low byte of a 32-bit register to 2, leaving the high bytes unchanged
-storing all 32 bits of the register into memory which would store 
  nonzero data in the high bytes, possibly containing sensitive information. "

In this case,even after doing a memset the compiler could copy some sensitive 
information from the 32 bit register into the padding bytes.
So, I feel it is necessary to implement it by copying it to a new equivalent 
struct.

Regards
Bhadrinath





Current thread: