[libvirt] [PATCH 01/11] tests: Don't test octal localhost IP in sockettest on macOS

Roman Bolshakov posted 11 patches 6 years, 5 months ago
[libvirt] [PATCH 01/11] tests: Don't test octal localhost IP in sockettest on macOS
Posted by Roman Bolshakov 6 years, 5 months ago
getaddrinfo on macOS doesn't interpret octal IPv4 addresses. Only
inet_aton can be used for that. Therefore, from macOS standpoint
"0177.0.0.01" is not the same as "127.0.0.1".

The issue was also discovered by python and dotnet core:
  https://bugs.python.org/issue27612
  https://github.com/dotnet/corefx/issues/8362

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
---
 tests/sockettest.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/sockettest.c b/tests/sockettest.c
index 859f02e51e..2b21352c13 100644
--- a/tests/sockettest.c
+++ b/tests/sockettest.c
@@ -465,7 +465,11 @@ mymain(void)
 
     DO_TEST_LOCALHOST("127.0.0.1", true);
     DO_TEST_LOCALHOST("2130706433", true);
+
+    /* Octal IPv4 doesn't work in getaddrinfo on macOS */
+#ifndef __APPLE__
     DO_TEST_LOCALHOST("0177.0.0.01", true);
+#endif
     DO_TEST_LOCALHOST("::1", true);
     DO_TEST_LOCALHOST("0::1", true);
     DO_TEST_LOCALHOST("0:0:0::1", true);
-- 
2.22.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 01/11] tests: Don't test octal localhost IP in sockettest on macOS
Posted by Daniel P. Berrangé 6 years, 5 months ago
On Wed, Aug 21, 2019 at 07:13:13PM +0300, Roman Bolshakov wrote:
> getaddrinfo on macOS doesn't interpret octal IPv4 addresses. Only
> inet_aton can be used for that. Therefore, from macOS standpoint
> "0177.0.0.01" is not the same as "127.0.0.1".
> 
> The issue was also discovered by python and dotnet core:
>   https://bugs.python.org/issue27612
>   https://github.com/dotnet/corefx/issues/8362
> 
> Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
> ---
>  tests/sockettest.c | 4 ++++
>  1 file changed, 4 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list