IP version happily accepts and returns invalid netmasks:
<pre>
% ::ip::version
4
</pre>
even worse, basically accepts all sorts of input:

<pre>
% ip::version
4
</pre>

I'm attaching a patch that makes things more strict