{"id":277785,"date":"2016-04-06T16:24:02","date_gmt":"2016-04-06T12:24:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=277785"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=277785","title":{"rendered":"\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0430\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445"},"content":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a47\/a38\/5ee\/a47a385eefc6de47ed417adef4e082ff.png\" align=\"left\"\/><br \/>  \u0427\u0430\u0441\u0442\u043e \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: \u043f\u0430\u0440\u043e\u043b\u0438, \u043a\u043b\u044e\u0447\u0438 \u0438 \u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0435. \u041e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c \u043e\u0442 \u0438\u0445 \u0441\u043b\u0435\u0434\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043d\u0435 \u043c\u043e\u0433 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043d\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f. \u0412 \u044d\u0442\u043e\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u043f\u043e\u0439\u0434\u0435\u0442 \u0440\u0435\u0447\u044c \u043e \u0442\u043e\u043c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <i>memset()<\/i>.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>memset()<\/h2>\n<p>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b \u0443\u0436\u0435 \u0447\u0438\u0442\u0430\u043b\u0438 <a href=\"https:\/\/habrahabr.ru\/company\/abbyy\/blog\/127259\/\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/aa246471(v=vs.60).aspx\"><i>memset()<\/i><\/a> \u0434\u043b\u044f \u0437\u0430\u0442\u0438\u0440\u0430\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438. \u041d\u043e \u043e\u043d\u0430 \u043d\u0435 \u0432 \u043f\u043e\u043b\u043d\u043e\u043c \u043e\u0431\u044a\u0435\u043c\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0438 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <i>memset()<\/i>. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043e\u0447\u0438\u0441\u0442\u043a\u043e\u0439 \u0431\u0443\u0444\u0435\u0440\u043e\u0432, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0442\u0435\u043a\u0435, \u043d\u043e \u0438 \u0441 \u0431\u0443\u0444\u0435\u0440\u0430\u043c\u0438, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<h2>\u0421\u0442\u0435\u043a<\/h2>\n<p>  \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0443\u0447\u0430\u0439 \u0438\u0437 \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u043d\u0430 \u0441\u0442\u0435\u043a\u0435.<\/p>\n<p>  \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043f\u0430\u0440\u043e\u043b\u0435\u043c:  <\/p>\n<pre><code class=\"cpp\">#include &lt;string&gt; #include &lt;functional&gt; #include &lt;iostream&gt;  \/\/\u041f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 struct PrivateData {   size_t m_hash;   char m_pswd[100]; };  \/\/\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0447\u0442\u043e-\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0441 \u043f\u0430\u0440\u043e\u043b\u0435\u043c void doSmth(PrivateData&amp; data) {   std::string s(data.m_pswd);   std::hash&lt;std::string&gt; hash_fn;    data.m_hash = hash_fn(s); }  \/\/\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0432\u0432\u043e\u0434\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0430\u0440\u043e\u043b\u044f int funcPswd() {   PrivateData data;   std::cin &gt;&gt; data.m_pswd;    doSmth(data);   memset(&amp;data, 0, sizeof(PrivateData));   return 1; }  int main() {   funcPswd();   return 0; }<\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u0441\u043b\u043e\u0432\u0435\u043d, \u043e\u043d \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u0438\u043d\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043c\u044b \u0441\u043e\u0431\u0435\u0440\u0435\u043c \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043f\u043e\u0434 \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a\u043e\u043c (\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b Visual Studio 2015), \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435. \u041f\u0430\u0440\u043e\u043b\u044c \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439 \u0445\u044d\u0448 \u0441\u0442\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. <\/p>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u043e\u0434 \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a\u043e\u043c Visual Studio:   <\/p>\n<pre><code class=\"cpp\">....      doSmth(data); 000000013F3072BF  lea         rcx,[data]   000000013F3072C3  call        doSmth (013F30153Ch)     memset(&amp;data, 0, sizeof(PrivateData)); 000000013F3072C8  mov         r8d,70h   000000013F3072CE  xor         edx,edx   000000013F3072D0  lea         rcx,[data]   000000013F3072D4  call        memset (013F301352h)     return 1; 000000013F3072D9  mov         eax,1   ....<\/code><\/pre>\n<p>  \u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c \u0432\u044b\u0437\u043e\u0432 \u043d\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>memset()<\/i>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0447\u0438\u0441\u0442\u0438\u0442 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. <\/p>\n<p>  \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c, \u043d\u043e \u043d\u0435\u0442, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0440\u0435\u043b\u0438\u0437-\u0432\u0435\u0440\u0441\u0438\u044e \u0441 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043a\u043e\u0434\u0430. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a\u0435, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:  <\/p>\n<pre><code class=\"cpp\">....  000000013F7A1035  call         std::operator&gt;&gt;&lt;char,std::char_traits&lt;char&gt; &gt; (013F7A18B0h)   000000013F7A103A  lea         rcx,[rsp+20h]   000000013F7A103F  call        doSmth (013F7A1170h)       return 0; 000000013F7A1044  xor         eax,eax    .... <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u0432\u0441\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432\u044b\u0437\u043e\u0432\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>memset()<\/i>, \u0443\u0434\u0430\u043b\u0435\u043d\u044b. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043b, \u0447\u0442\u043e \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0447\u0438\u0449\u0430\u044e\u0449\u0443\u044e \u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f. \u042d\u0442\u043e \u043d\u0435 \u043e\u0448\u0438\u0431\u043a\u0430, \u0430 \u0437\u0430\u043a\u043e\u043d\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430. \u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u044f\u0437\u044b\u043a\u0430 \u0432\u044b\u0437\u043e\u0432 <i>memset()<\/i> \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u0430\u043b\u0435\u0435 \u0431\u0443\u0444\u0435\u0440 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u0410 \u0440\u0430\u0437 \u0442\u0430\u043a, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 <i>memset()<\/i> \u043d\u0435 \u043e\u043a\u0430\u0436\u0435\u0442 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430\u0448\u0438 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u044b \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438, \u0447\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u043b\u043e\u0445\u043e. <\/p>\n<h2>\u041a\u0443\u0447\u0430<\/h2>\n<p>  \u0410 \u0432\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u043c\u0441\u044f \u0433\u043b\u0443\u0431\u0436\u0435. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0430 \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u044b \u0432 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>malloc <\/i> \u0438\u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <i>new<\/i>.<\/p>\n<p>  \u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 \u043a\u043e\u0434 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 <i>malloc<\/i>:  <\/p>\n<pre><code class=\"cpp\">#include &lt;string&gt; #include &lt;functional&gt; #include &lt;iostream&gt;  struct PrivateData {   size_t m_hash;   char m_pswd[100]; };  void doSmth(PrivateData&amp; data) {   std::string s(data.m_pswd);   std::hash&lt;std::string&gt; hash_fn;    data.m_hash = hash_fn(s); }  int funcPswd() {   PrivateData* data = (PrivateData*)malloc(sizeof(PrivateData));   std::cin &gt;&gt; data-&gt;m_pswd;   doSmth(*data);   memset(data, 0, sizeof(PrivateData));   free(data);   return 1; }  int main() {   funcPswd();   return 0; }<\/code><\/pre>\n<p>  \u0411\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c Release-\u0432\u0435\u0440\u0441\u0438\u044e, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 Debug \u0432\u0441\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043d\u0430 \u0441\u0432\u043e\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445. \u041f\u043e\u0441\u043b\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0432 Visual Studio 2015 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434:  <\/p>\n<pre><code class=\"cpp\">....  000000013FBB1021  mov         rcx,         qword ptr [__imp_std::cin (013FBB30D8h)]   000000013FBB1028  mov         rbx,rax   000000013FBB102B  lea         rdx,[rax+8]   000000013FBB102F  call         std::operator&gt;&gt;&lt;char,std::char_traits&lt;char&gt; &gt; (013FBB18B0h)   000000013FBB1034  mov         rcx,rbx   000000013FBB1037  call        doSmth (013FBB1170h)   000000013FBB103C  xor         edx,edx   000000013FBB103E  mov         rcx,rbx   000000013FBB1041  lea         r8d,[rdx+70h]   000000013FBB1045  call        memset (013FBB2A2Eh)   000000013FBB104A  mov         rcx,rbx   000000013FBB104D  call        qword ptr [__imp_free (013FBB3170h)]       return 0; 000000013FBB1053  xor         eax,eax   .... <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 Visual Studio \u0432\u0441\u0435 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u043d\u0430\u0448\u0430 \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0431\u0443\u0434\u0443\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <b>gcc<\/b> \u0432\u0435\u0440\u0441\u0438\u0438 5.2.1 \u0438 <b>clang <\/b> \u0432\u0435\u0440\u0441\u0438\u0438 3.7.0.<\/p>\n<p>  \u0414\u043b\u044f <b>gcc<\/b> \u0438 <b>clang <\/b> \u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043b \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434, \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0440\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e\u0441\u044f \u0432 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0434\u043e \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0438 \u043f\u043e\u0441\u043b\u0435 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u043f\u0430\u043c\u044f\u0442\u0438. \u042f \u0440\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u0430\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e \u0443\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u0445 \u0442\u0430\u043a\u043e\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043a\u0430\u043a \u043f\u043e\u0432\u0435\u0434\u0435\u0442 \u0441\u0435\u0431\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435. \u041d\u043e \u0434\u043b\u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b \u0441\u0435\u0431\u0435 \u0442\u0430\u043a\u0443\u044e \u0432\u043e\u043b\u044c\u043d\u043e\u0441\u0442\u044c.  <\/p>\n<pre><code class=\"cpp\">.... #include &quot;string.h&quot; .... size_t len = strlen(data-&gt;m_pswd); for (int i = 0; i &lt; len; ++i)   printf(&quot;%c&quot;, data-&gt;m_pswd[i]); printf(&quot;| %zu \\n&quot;, data-&gt;m_hash); memset(data, 0, sizeof(PrivateData)); free(data); for (int i = 0; i &lt; len; ++i)   printf(&quot;%c&quot;, data-&gt;m_pswd[i]); printf(&quot;| %zu \\n&quot;, data-&gt;m_hash); .... <\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a, \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c <b>gcc<\/b>:  <\/p>\n<pre><code class=\"cpp\">movq (%r12), %rsi movl $.LC2, %edi xorl %eax, %eax call printf movq %r12, %rdi call free<\/code><\/pre>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0440\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u043a\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e (<i>printf<\/i>) \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>free()<\/i>, \u0430 \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>memset()<\/i> \u0443\u0434\u0430\u043b\u0435\u043d. \u0415\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u0434 \u0438 \u0432\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u043e\u043b\u044c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u00abMyTopSecret\u00bb), \u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u044b\u0432\u043e\u0434 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d:<\/p>\n<p>  MyTopSecret| 7882334103340833743 <\/p>\n<p>  MyTopSecret| 0<\/p>\n<p>  \u0425\u044d\u0448 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f. \u0412\u0438\u0434\u0438\u043c\u043e \u044d\u0442\u043e \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u043f\u0430\u043c\u044f\u0442\u0438. \u041d\u0430\u0448 \u0436\u0435 \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043f\u0430\u0440\u043e\u043b\u044c \u00abMyTopSecret\u00bb, \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u0432 \u043d\u0435\u043f\u0440\u0438\u043a\u043e\u0441\u043d\u043e\u0432\u0435\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. <\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0434\u043b\u044f <b>clang<\/b>:  <\/p>\n<pre><code class=\"cpp\">movq (%r14), %rsi movl $.L.str.1, %edi xorl %eax, %eax callq printf movq %r14, %rdi callq free<\/code><\/pre>\n<p>  \u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443, \u0432\u044b\u0437\u043e\u0432 <i>memset()<\/i> \u0443\u0434\u0430\u043b\u0435\u043d. \u0412\u044b\u0432\u043e\u0434 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  MyTopSecret| 7882334103340833743 <\/p>\n<p>  MyTopSecret| 0<\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0438 <b>gcc<\/b>, \u0438 <b>clang <\/b> \u0440\u0435\u0448\u0438\u043b\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434. \u0422\u0430\u043a \u043a\u0430\u043a \u043f\u0430\u043c\u044f\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>memset()<\/i> \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f, \u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b \u0441\u0447\u0438\u0442\u0430\u044e\u0442 \u044d\u0442\u043e\u0442 \u0432\u044b\u0437\u043e\u0432 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u043c \u0438 \u0443\u0434\u0430\u043b\u044f\u044e\u0442 \u0435\u0433\u043e.<\/p>\n<p>  \u041a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b \u043f\u0440\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0443\u0434\u0430\u043b\u044f\u044e\u0442 \u0432\u044b\u0437\u043e\u0432 <i>memset()<\/i> \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0438 \u0441\u0442\u0435\u043a\u043e\u0432\u043e\u0439 \u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u041d\u0443 \u0438 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043a\u0430\u043a \u043f\u043e\u0432\u0435\u0434\u0443\u0442 \u0441\u0435\u0431\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b \u043f\u0440\u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <i>new<\/i>.<\/p>\n<p>  \u0415\u0449\u0435 \u0440\u0430\u0437 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u0434:   <\/p>\n<pre><code class=\"cpp\">#include &lt;string&gt; #include &lt;functional&gt; #include &lt;iostream&gt; #include &quot;string.h&quot;  struct PrivateData {   size_t m_hash;   char m_pswd[100]; };  void doSmth(PrivateData&amp; data) {   std::string s(data.m_pswd);   std::hash&lt;std::string&gt; hash_fn;    data.m_hash = hash_fn(s); }  int funcPswd() {   PrivateData* data = new PrivateData();   std::cin &gt;&gt; data-&gt;m_pswd;   doSmth(*data);   memset(data, 0, sizeof(PrivateData));   delete data;   return 1; }  int main() {   funcPswd();   return 0; }<\/code><\/pre>\n<p>  Visual Studio \u0434\u043e\u0431\u0440\u043e\u0441\u043e\u0432\u0435\u0441\u0442\u043d\u043e \u0447\u0438\u0441\u0442\u0438\u0442 \u043f\u0430\u043c\u044f\u0442\u044c:  <\/p>\n<pre><code class=\"cpp\">000000013FEB1044  call        doSmth (013FEB1180h)   000000013FEB1049  xor         edx,edx   000000013FEB104B  mov         rcx,rbx   000000013FEB104E  lea         r8d,[rdx+70h]   000000013FEB1052  call        memset (013FEB2A3Eh)   000000013FEB1057  mov         edx,70h   000000013FEB105C  mov         rcx,rbx   000000013FEB105F  call        operator delete (013FEB1BA8h)       return 0; 000000013FEB1064  xor         eax,eax  <\/code><\/pre>\n<p>  \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 <b>gcc<\/b> \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u0448\u0438\u043b \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u0434\u043b\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u043f\u0430\u043c\u044f\u0442\u0438:  <\/p>\n<pre><code class=\"cpp\">call printf movq %r13, %rdi movq %rbp, %rcx xorl %eax, %eax andq $-8, %rdi movq $0, 0(%rbp) movq $0, 104(%rbp) subq %rdi, %rcx addl $112, %ecx shrl $3, %ecx rep stosq movq %rbp, %rdi call _ZdlPv<\/code><\/pre>\n<p>  \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u0438 \u0432\u044b\u0432\u043e\u0434 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d, \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u044b:<\/p>\n<p>  MyTopSecret| 7882334103340833743 <\/p>\n<p>  | 0<\/p>\n<p>  \u0410 \u0432\u043e\u0442 <b>clang<\/b> \u0440\u0435\u0448\u0438\u043b \u043e\u043f\u044f\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u0434 \u0438 \u0432\u044b\u0440\u0435\u0437\u0430\u043b \u00ab\u043d\u0435\u043d\u0443\u0436\u043d\u0443\u044e\u00bb \u0444\u0443\u043d\u043a\u0446\u0438\u044e:  <\/p>\n<pre><code class=\"cpp\">movq (%r14), %rsi movl $.L.str.1, %edi xorl %eax, %eax callq printf movq %r14, %rdi callq _ZdlPv<\/code><\/pre>\n<p>  \u0420\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u0430\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043f\u0430\u043c\u044f\u0442\u0438:<\/p>\n<p>  MyTopSecret| 7882334103340833743 <\/p>\n<p>  MyTopSecret| 0<\/p>\n<p>  \u041f\u0430\u0440\u043e\u043b\u044c \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u0436\u0438\u0442\u044c \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0436\u0434\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0435\u0433\u043e \u0443\u043a\u0440\u0430\u0434\u0443\u0442.<\/p>\n<p>  \u041f\u043e\u0434\u0432\u0435\u0434\u0435\u043c \u0438\u0442\u043e\u0433\u0438. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044f \u043a\u043e\u0434, \u043c\u043e\u0436\u0435\u0442 \u0443\u0431\u0440\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>memset()<\/i> \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043b\u044e\u0431\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u043a\u0430\u043a \u0441\u0442\u0435\u043a\u043e\u0432\u043e\u0439, \u0442\u0430\u043a \u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e Visual Studio \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u043b\u0430 \u0432\u044b\u0437\u043e\u0432\u044b <i>memset()<\/i> \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u044d\u0442\u043e \u043d\u0438 \u0432 \u043a\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043b\u044c\u0437\u044f. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u043b\u0430\u0433\u043e\u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u044d\u0444\u0444\u0435\u043a\u0442 \u043f\u0440\u043e\u044f\u0432\u0438\u0442 \u0441\u0435\u0431\u044f. \u0418\u0437 \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0433\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0442\u0435\u043a\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u043b\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <i>memset()<\/i>.<\/p>\n<p>  \u041a\u0430\u043a \u0436\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435? <\/p>\n<p>  \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u043f\u0430\u043c\u044f\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0443\u0434\u0430\u043b\u0435\u043d\u044b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430.<\/p>\n<p>  \u0412 Visual Studio, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/hardware\/ff562768%28v=vs.85%29.aspx\"><i>RtlSecureZeroMemory<\/i><\/a>. \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 C11 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"http:\/\/en.cppreference.com\/w\/c\/string\/byte\/memset\"><i>memset_s<\/i><\/a>. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0412 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u043a\u0430\u043a \u0435\u0451 \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u0412\u043e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432.<\/p>\n<p>  \u0412\u0430\u0440\u0438\u0430\u043d\u0442 <a href=\"https:\/\/www.securecoding.cert.org\/confluence\/display\/c\/MSC06-C.+Beware+of+compiler+optimizations\">N1<\/a>.  <\/p>\n<pre><code class=\"cpp\">errno_t memset_s(void *v, rsize_t smax, int c, rsize_t n) {   if (v == NULL) return EINVAL;   if (smax &gt; RSIZE_MAX) return EINVAL;   if (n &gt; smax) return EINVAL;   volatile unsigned char *p = v;   while (smax-- &amp;&amp; n--) {     *p++ = c;   }   return 0; }<\/code><\/pre>\n<p>  \u0412\u0430\u0440\u0438\u0430\u043d\u0442 <a href=\"http:\/\/stackoverflow.com\/a\/13299459\/965097\">N2<\/a>.  <\/p>\n<pre><code class=\"cpp\">void secure_zero(void *s, size_t n) {     volatile char *p = s;     while (n--) *p++ = 0; }<\/code><\/pre>\n<p>  \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0434\u0443\u0442 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u0434\u0435\u043b\u0430\u044e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0441\u0435\u0432\u0434\u043e\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0438\u0442\u044c \u0430\u0442\u0430\u043a\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0437\u0430\u043c\u0435\u0440\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0418\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 PVS-Studio \u0443\u043c\u0435\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438. \u041e\u043d \u0441\u0438\u0433\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438 <a href=\"http:\/\/www.viva64.com\/ru\/d\/0208\/\">V597<\/a>. \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430, \u043a\u0430\u043a \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u0430 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0430 \u0432\u0430\u0436\u043d\u0430. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043c\u043d\u043e\u0433\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u0441\u0447\u0438\u0442\u0430\u044e\u0442, \u0447\u0442\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u00ab\u043f\u0440\u0438\u0434\u0438\u0440\u0430\u0435\u0442\u0441\u044f\u00bb \u043a \u0438\u0445 \u043a\u043e\u0434\u0443 \u0438 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0435\u0442. \u0412\u0435\u0434\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0432\u0438\u0434\u0438\u0442 \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>memset()<\/i> \u0432 \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a\u0435, \u0437\u0430\u0431\u044b\u0432 \u0447\u0442\u043e \u044d\u0442\u043e \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f.<\/p>\n<p>  <a href=\"http:\/\/www.viva64.com\/en\/b\/0388\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/35e\/064\/ddf\/35e064ddf91f5d99b620384893909ff7.png\" \/><\/div>\n<p><\/a><br \/>  \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u0441 \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u0439 \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u0435\u0439, \u0442\u043e \u043f\u0440\u043e\u0448\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434: Roman Fomichev. <a href=\"http:\/\/www.viva64.com\/en\/b\/0388\/\">Safe Clearing of Private Data<\/a>.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u0441\u0442\u0430\u0442\u044c\u044e \u0438 \u0435\u0441\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441?<\/b><\/p>\n<div class=\"spoiler_text\">\u0427\u0430\u0441\u0442\u043e \u043a \u043d\u0430\u0448\u0438\u043c \u0441\u0442\u0430\u0442\u044c\u044f\u043c \u0437\u0430\u0434\u0430\u044e\u0442 \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b. \u041e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u043d\u0438\u0445 \u043c\u044b \u0441\u043e\u0431\u0440\u0430\u043b\u0438 \u0437\u0434\u0435\u0441\u044c: <a href=\"http:\/\/www.viva64.com\/ru\/a\/0085\/\">\u041e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e PVS-Studio, \u0432\u0435\u0440\u0441\u0438\u044f 2015<\/a>. \u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u044c\u0442\u0435\u0441\u044c \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c.  <\/div>\n<\/div>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/281072\/\"> https:\/\/habrahabr.ru\/post\/281072\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a47\/a38\/5ee\/a47a385eefc6de47ed417adef4e082ff.png\" align=\"left\"\/><br \/>  \u0427\u0430\u0441\u0442\u043e \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: \u043f\u0430\u0440\u043e\u043b\u0438, \u043a\u043b\u044e\u0447\u0438 \u0438 \u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0435. \u041e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c \u043e\u0442 \u0438\u0445 \u0441\u043b\u0435\u0434\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043d\u0435 \u043c\u043e\u0433 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043d\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f. \u0412 \u044d\u0442\u043e\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u043f\u043e\u0439\u0434\u0435\u0442 \u0440\u0435\u0447\u044c \u043e \u0442\u043e\u043c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <i>memset()<\/i>.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-277785","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/277785","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=277785"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/277785\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=277785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=277785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=277785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}