saghul / pycares

Python interface for c-ares
https://pypi.org/project/pycares/
MIT License
163 stars 74 forks source link

🔗 Fix documentaion of getnameinfo() + Add support of IPv6 link-local addresses (#121) #122

Closed socketpair closed 4 years ago

socketpair commented 4 years ago

Disgusting library. I will never use it anymore. Sorry, but it has code from 2005 with obvious kindergardten bugs. I guess plenty security bugs.

socketpair commented 4 years ago

I've done all the changes I wanted.

saghul commented 4 years ago

Left one more question.

socketpair commented 4 years ago

.

saghul commented 4 years ago

No, I'm strongly confident that for IPv6 it always must be a 4-item tuple.

Can you elaborate? Even getnameinfo(3) doesn't say they are mandatory, one can memset the struct to 0, just fill in the address and port and it doesn't fail. And Python works this way, too, so there is precedent.

socketpair commented 4 years ago

C API wants a complete structure. This means all fields are mandatory, and the last two might be zero. Yes. But C API does not allow to pass half of the structure. Same with Python.

People who construct such a tuple from scratch (by filling fields got from somewhere) are definitely doing it wrong. Such tuples should only be constructed from getaddrinfo() or so. Unfortunately, Python API uses just plain tuples instead of dataclasses or named tuples.

This is exactly the reason for losing link-local functionality in myriads of program. The bad design of Python API.

As you can see these tuples have 4 items. With zeroes filled in.

изображение

saghul commented 4 years ago

Gotcha, makes sense!