for copying structs, for most compilers, this seems like a "more likely correct" solution (ex: if memcpy is handled poorly, ...).
-
-
Replying to @cr88192 @RichFelker
Yes, exactly. Unfortunately C doesn't have struct assignment by value, which is a shame. Feels like a C-y operation to me and not C++-like.
1 reply 0 retweets 0 likes -
Replying to @sortiecat @cr88192
Huh? Of course C has struct assignment by value.
1 reply 0 retweets 1 like -
Replying to @RichFelker @cr88192
Huh. You're right. Not sure where I got this impression from. Yay. Though C doesn't have struct == so my memcmp concerns still exist.
2 replies 0 retweets 1 like -
Replying to @sortiecat @cr88192
Yes. But memcmp for structs is often wrong unless you know they have no padding, & no members that need comparison more nuanced than memcmp.
1 reply 0 retweets 1 like -
Replying to @RichFelker @cr88192
I continue to be terrified of bugs relating to uninitialized padding and struct uninitialized padding copied between security boundaries
1 reply 1 retweet 2 likes -
Replying to @sortiecat @cr88192
This is a strong argument for not copying structs at all but just assigning individual members.
1 reply 0 retweets 2 likes -
Replying to @RichFelker @cr88192
struct foo a = b; struct foo a = { 0 }; a.baz = b.baz; a.qux = b.qux; Much more boilerplate. :/
2 replies 0 retweets 1 like -
Does { 0 } promise to initialize padding to 0? Or do I need memset for that?
2 replies 0 retweets 2 likes -
I would like a hardening mode where the compiler forces all struct padding to be zero. Concerned about leaking stack cookie, for instance.
1 reply 0 retweets 0 likes
Well stack cookie should be erased *before* the memory can be reused.
-
-
Replying to @RichFelker @cr88192
Right that is an obvious thing to do, I should have checked the stack check assembly. Still concerned about similar leaks.
0 replies 0 retweets 0 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.