[Mimedefang] [Patch] relay_is_* not ipv6 friendly (IPv4 Compatible "patch")

David F. Skoll dfs at roaringpenguin.com
Wed Feb 3 15:56:54 EST 2010


- wrote:

> Comments:

>>             if (strchr(data->hostip, '.')) {

> This conditional is redundant.

No, it is not.  inet_ntop does not *have* to use the form
::ffff:a.b.c.d for IPv4-compatible addresses.  It's allowed to do
that, but not mandated to.  It could use ::ffff:aabb:ccdd

If an implementation's inet_ntop does not do it... well, too bad.  The
Perl code ends up seeing an IPv6 address.

> ....
>             char const *lastcolon = strrchr(data->hostip, ':');
>             if (lastcolon)
>                 strncpy((char *)data->hostip,++lastcolon,16);
>             }
> ....

> We don't need the while loop which is UNBOUNDED by length.

Again... I trust inet_ntop.  And I don't write code that tries to cope with
hardware faults because that's impossible by definition.

strncpy(), btw, is a horrible function because it's not guaranteed to
zero-terminate the result.  Yes, I know that can "never" happen in this case,
but an unbounded loop can also "never" happen.

Regards,

David.



More information about the MIMEDefang mailing list