<story><title>It&apos;s 2023 and memory overwrite bugs are not just a thing theyre still number one</title><url>https://www.theregister.com/2023/06/29/cwe_top_25_2023/</url></story><parent_chain><item><author>WalterBright</author><text>Array bounds errors in C, the number 1 problem, can be mitigated by adding this proposal to fix C:&lt;p&gt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;www.digitalmars.com&amp;#x2F;articles&amp;#x2F;C-biggest-mistake.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https:&amp;#x2F;&amp;#x2F;www.digitalmars.com&amp;#x2F;articles&amp;#x2F;C-biggest-mistake.html&lt;/a&gt;&lt;p&gt;I don&amp;#x27;t really understand the resistance to it. It does not affect existing code at all, it&amp;#x27;s simple, it&amp;#x27;s easy to implement, and its worth has been proven in D. (It&amp;#x27;s one of D&amp;#x27;s most popular features.)</text></item><item><author>eatonphil</author><text>Direct link to the list they&amp;#x27;re talking about: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;cwe.mitre.org&amp;#x2F;data&amp;#x2F;definitions&amp;#x2F;1425.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https:&amp;#x2F;&amp;#x2F;cwe.mitre.org&amp;#x2F;data&amp;#x2F;definitions&amp;#x2F;1425.html&lt;/a&gt;.&lt;p&gt;And the list (top 10):&lt;p&gt;* Out-of-bounds Write&lt;p&gt;* Improper Neutralization of Input During Web Page Generation (&amp;#x27;Cross-site Scripting&amp;#x27;)&lt;p&gt;* Improper Neutralization of Special Elements used in an SQL Command (&amp;#x27;SQL Injection&amp;#x27;)&lt;p&gt;* Use After Free&lt;p&gt;* Improper Neutralization of Special Elements used in an OS Command (&amp;#x27;OS Command Injection&amp;#x27;)&lt;p&gt;* Improper Input Validation&lt;p&gt;* Out-of-bounds Read&lt;p&gt;* Improper Limitation of a Pathname to a Restricted Directory (&amp;#x27;Path Traversal&amp;#x27;)&lt;p&gt;* Cross-Site Request Forgery (CSRF)&lt;p&gt;* Unrestricted Upload of File with Dangerous Type</text></item></parent_chain><comment><author>eschaton</author><text>I expect that there are probably a few significant points of technical resistance:&lt;p&gt;1. Introducing a new syntactic token (`..`) when there are already a lot of those in C.&lt;p&gt;2. Transforming an argument `char foo[..]` to the argument pair `const size_t foo_dim, char * const foo` leaves out a ton of existing APIs that order their arguments differently or breaks their binary compatibility.&lt;p&gt;3. It doesn’t accommodate APIs where both an element size and element count are passed, e.g. `fread(3)`.&lt;p&gt;C is a long-lived language so modifications like this have to work within a very large existing body of code. They can be made to work—blocks have worked out wonderfully, for example, by essentially saying they’re only for new APIs—but this type of extension requires a lot of consideration beyond “we could tweak the syntax and get this feature.”</text></comment>
<story><title>It&apos;s 2023 and memory overwrite bugs are not just a thing theyre still number one</title><url>https://www.theregister.com/2023/06/29/cwe_top_25_2023/</url></story><parent_chain><item><author>WalterBright</author><text>Array bounds errors in C, the number 1 problem, can be mitigated by adding this proposal to fix C:&lt;p&gt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;www.digitalmars.com&amp;#x2F;articles&amp;#x2F;C-biggest-mistake.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https:&amp;#x2F;&amp;#x2F;www.digitalmars.com&amp;#x2F;articles&amp;#x2F;C-biggest-mistake.html&lt;/a&gt;&lt;p&gt;I don&amp;#x27;t really understand the resistance to it. It does not affect existing code at all, it&amp;#x27;s simple, it&amp;#x27;s easy to implement, and its worth has been proven in D. (It&amp;#x27;s one of D&amp;#x27;s most popular features.)</text></item><item><author>eatonphil</author><text>Direct link to the list they&amp;#x27;re talking about: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;cwe.mitre.org&amp;#x2F;data&amp;#x2F;definitions&amp;#x2F;1425.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;https:&amp;#x2F;&amp;#x2F;cwe.mitre.org&amp;#x2F;data&amp;#x2F;definitions&amp;#x2F;1425.html&lt;/a&gt;.&lt;p&gt;And the list (top 10):&lt;p&gt;* Out-of-bounds Write&lt;p&gt;* Improper Neutralization of Input During Web Page Generation (&amp;#x27;Cross-site Scripting&amp;#x27;)&lt;p&gt;* Improper Neutralization of Special Elements used in an SQL Command (&amp;#x27;SQL Injection&amp;#x27;)&lt;p&gt;* Use After Free&lt;p&gt;* Improper Neutralization of Special Elements used in an OS Command (&amp;#x27;OS Command Injection&amp;#x27;)&lt;p&gt;* Improper Input Validation&lt;p&gt;* Out-of-bounds Read&lt;p&gt;* Improper Limitation of a Pathname to a Restricted Directory (&amp;#x27;Path Traversal&amp;#x27;)&lt;p&gt;* Cross-Site Request Forgery (CSRF)&lt;p&gt;* Unrestricted Upload of File with Dangerous Type</text></item></parent_chain><comment><author>mjevans</author><text>That, and please &amp;#x27;fix struct packing&amp;#x27;.  For a moment I considered, &amp;#x27;oh just pass a struct around as the logical tuple of this data instead&amp;#x27; and then I remembered they don&amp;#x27;t have to conform to any particular signature.&lt;p&gt;&lt;pre&gt;&lt;code&gt;    extern void foo(size_t dim, char a[dim]);
    struct vecStr {size_t dim; char a[dim];};
    &amp;#x2F;&amp;#x2F; Not guaranteed ABI compatibility with above
    extern void foo(struct vecStr);
&lt;/code&gt;&lt;/pre&gt;
It would be really nice if, formally, structs mostly happened to work as expected (if ordered reasonably, behave as packed&amp;#x2F;smallest) and if there were language, not just some compiler, supported prefix attributes that enforced either packed (smallest), fastest, or if some other methods are needed later those.  Possibly manually specifying a target alignment.&lt;p&gt;Also at this point far too much code depends on signed integers as the default, but it would be nice if for added clarity stdint.h and similar had complimentary sintX_t equivalents to uintX_t even though sint8_t would just be a syntax alias for int8_t (preferably the reverse).</text></comment>