3 ms·
> explain to me why a function that is clearly intended to create a side effect that is visible outside the process This is simply not accurate. memset_s provi
by dagenix 5y ago
> explain to me why a function that is clearly intended to create a side effect that is visible outside the process
This is simply not accurate. memset_s provides that guarantee. memset does not. It would appear that you have been under the impression that it did. However, it did not.
- rurban 5y agoIt does not. Almost all memset_s implementations are broken, just mine not. memset_s just ensures that the unsane compiler will not optimize it away, whilst it should also ensure that is fenced. Otherwise you can still read the memory from the cache. Calling the ordinary memset_s secure is a bug, it's a mere convenience function.
- dagenix 5y agoI don't follow - how do memory fences make a meaningful difference in security?
- overgard 5y agoDoesn't it seem bad that the default that's been taught is wrong? Admittedly I haven't read a C programming book since 1998 because I've been coding that long, but, it strikes me as incredibly fucked that you need a separate memset_s to mean "I'm not fucking around". When I learned C, memset just meant, uh, set this memory, it was pretty straightforward.
- josephcsible 5y ago> the default that's been taught is wrong There's a big difference between you not liking something and it being wrong. You want to make the common case slower for everyone so that you don't have to learn one extra rule for your uncommon case. > it strikes me as incredibly fucked that you need a separate memset_s to mean "I'm not fucking around". When I learned C, memset just meant, uh, set this memory, it was pretty straightforward. I don't think it's ever worked the way you want it to work.