Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad output for $ip->print method #4

Closed
hannaeko opened this issue Jan 23, 2023 · 1 comment
Closed

Bad output for $ip->print method #4

hannaeko opened this issue Jan 23, 2023 · 1 comment

Comments

@hannaeko
Copy link

Hello,

I have run into an issue with the Net::IP::XS::print method when trying to use it with IPv6 subnet.

perl -MNet::IP::XS -e 'my $ip = new Net::IP::XS ("::1/128" ); print $ip->print . "\n"'
0��7V::1/128

After investigating I suspect a uninitialized buffer in the NI_print function. I modified it like this,

diff --git a/object.c b/object.c
index e967c61..fb47059 100644
--- a/object.c
+++ b/object.c
@@ -472,6 +472,7 @@ NI_print(SV *ipo, char *buf, int maxlen)
     const char *second_ip;
     int res;
     char mybuf[MAX_IPV6_STR_LEN];
+    mybuf[0] = '\0';
 
     is_prefix = NI_hv_get_iv(ipo, "is_prefix", 9);

and it seems to work after that.

I'll happy to open a pull request to fix the issue if you want.

Thanks,
Gaël

@tomhrr
Copy link
Owner

tomhrr commented Jan 23, 2023

Thanks, this fix has now been applied. 0.22 has been uploaded to CPAN and should be available shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants