[Issue 20871] New: std.socket.UnixAddress @trusted functions can corrupt memory if inherited from

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu May 28 11:40:51 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=20871

          Issue ID: 20871
           Summary: std.socket.UnixAddress @trusted functions can corrupt
                    memory if inherited from
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Keywords: safe
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: pro.mathias.lang at gmail.com

```
import std.socket;
import std.stdio;

class Oops : UnixAddress
{
    override void setNameLen (socklen_t) @safe
    {
        this._nameLen = 99999;
    }
}

void main() @safe
{
    auto un = new Oops();
    un.setNameLen(0);
    writeln(un.path());
}
```

```
dmd -preview=dip1000 -run foo.d
????????????????????????????????????????????????????????????????????????????????????????????????????????!�@h����!�@h���"�@h����"�@h���#�@h����#�@h���$�@h����$�@h���%�@h����%�@h���&�@h����&�@h���'�@h����'�@h���(�@h����(�@h���)�@h����)�@h���*�@h����*�@h���+�@h����+�@h���,�@h����,�@h���-�@h����-�@h���.�@h����.�@h���/�@h����/�@h���@h���
```

--


More information about the Digitalmars-d-bugs mailing list