5 ms·
When I fell down into the rabbit hole of DNS, I wrote code to just encode and decode DNS packets [1]. All the existing libraries [2] had a complex API that pro
by spc476 8y ago
When I fell down into the rabbit hole of DNS, I wrote code to just encode and decode DNS packets [1]. All the existing libraries [2] had a complex API that provided a separate function for querying a few record types (A, AAAA, MX, TXT, SRV, maybe NS and SOA), leaving the rest unimplemented. They also tend to have complex network architectures to handle retries, caching, and parallel queries which could be hard to integrate into a project that had an existing network framework.
Mine? Just two functions: dns_encode() and dns_decode(). No I/O. No malloc().
[1] https://github.com/spc476/SPCDNS https://github.com/spc476/SPCDNS
[2] The ones I was looking at are written in C.
- lifthrasiir 8y ago> No malloc(). ...by having your own arena allocator! I do agree that it is quite doable in this particular case, but I always remember that a custom memory allocator of OpenSSL made Heartbleed much more devastating.
- spc476 8y ago... of memory passed in by the user! So it's up to the caller to make sure memory contains unclassified information.