Bug#899267: Reopen: Bug#899267: ruby2.5: FTBFS on kfreebsd-any

2018-06-10 Thread Antonio Terceiro
On Sun, 10 Jun 2018 23:38:18 +0200 Svante Signell  
wrote:
> reopen -1
> found 899267 2.5.1-2
> thanks
> 
> Hello,
> 
> Unfortunately the patch 0006-fix-kfreebsd-build.patch was not applied,
> resulting in a failing build. I'm attaching that file again, now named 
> 0007-fix-kfreebsd-build.patch

Was this patch submitted upstream?


signature.asc
Description: PGP signature


Bug#899267: Reopen: Bug#899267: ruby2.5: FTBFS on kfreebsd-any

2018-06-10 Thread Svante Signell
reopen -1
found 899267 2.5.1-2
thanks

Hello,

Unfortunately the patch 0006-fix-kfreebsd-build.patch was not applied,
resulting in a failing build. I'm attaching that file again, now named 
0007-fix-kfreebsd-build.patch

Thanks!
On Mon, 2018-05-21 at 21:45 +, Debian Bug Tracking System wrote:
> Thank you for filing a new Bug report with Debian.
> 
> If you wish to submit further information on this problem, please
> send it to 899...@bugs.debian.org.
Index: ruby2.5-2.5.1/ext/socket/option.c
===
--- ruby2.5-2.5.1.orig/ext/socket/option.c
+++ ruby2.5-2.5.1/ext/socket/option.c
@@ -10,6 +10,7 @@ VALUE rb_cSockOpt;
 #if defined(__linux__) || \
 defined(__GNU__) /* GNU/Hurd */ || \
 defined(__FreeBSD__) || \
+defined(__FreeBSD_kernel__) || \
 defined(__DragonFly__) || \
 defined(__APPLE__) || \
 defined(_WIN32) || \
Index: ruby2.5-2.5.1/ext/socket/raddrinfo.c
===
--- ruby2.5-2.5.1.orig/ext/socket/raddrinfo.c
+++ ruby2.5-2.5.1/ext/socket/raddrinfo.c
@@ -1670,10 +1670,21 @@ addrinfo_mload(VALUE self, VALUE ary)
 INIT_SOCKADDR_UN(&uaddr, sizeof(struct sockaddr_un));
 
 StringValue(v);
+#ifdef __FreeBSD_kernel__
+	/* sys/un.h defines struct sockaddr_un as:
+	   char sun_path[104];
+	   char __sun_user_compat[4];
+	*/
+if (sizeof(uaddr.sun_path) + 4 < (size_t)RSTRING_LEN(v))
+rb_raise(rb_eSocket,
+"too long AF_UNIX path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)",
+(size_t)RSTRING_LEN(v), sizeof(uaddr.sun_path) + 4);
+#else
 if (sizeof(uaddr.sun_path) < (size_t)RSTRING_LEN(v))
 rb_raise(rb_eSocket,
 "too long AF_UNIX path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)",
 (size_t)RSTRING_LEN(v), sizeof(uaddr.sun_path));
+#endif
 memcpy(uaddr.sun_path, RSTRING_PTR(v), RSTRING_LEN(v));
 len = (socklen_t)sizeof(uaddr);
 memcpy(&ss, &uaddr, len);
@@ -2319,10 +2330,21 @@ addrinfo_unix_path(VALUE self)
 if (e < s)
 rb_raise(rb_eSocket, "too short AF_UNIX address: %"PRIuSIZE" bytes given for minimum %"PRIuSIZE" bytes.",
 (size_t)rai->sockaddr_len, (size_t)(s - (char *)addr));
+#ifdef __FreeBSD_kernel__
+	/* sys/un.h defines struct sockaddr_un as:
+	   char sun_path[104];
+	   char __sun_user_compat[4];
+	*/
+if (addr->sun_path + sizeof(addr->sun_path) + 4 < e)
+rb_raise(rb_eSocket,
+"too long AF_UNIX path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)",
+(size_t)(e - addr->sun_path), sizeof(addr->sun_path) + 4);
+#else
 if (addr->sun_path + sizeof(addr->sun_path) < e)
 rb_raise(rb_eSocket,
 "too long AF_UNIX path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)",
 (size_t)(e - addr->sun_path), sizeof(addr->sun_path));
+#endif
 while (s < e && *(e-1) == '\0')
 e--;
 return rb_str_new(s, e-s);
Index: ruby2.5-2.5.1/test/fiddle/test_handle.rb
===
--- ruby2.5-2.5.1.orig/test/fiddle/test_handle.rb
+++ ruby2.5-2.5.1/test/fiddle/test_handle.rb
@@ -169,6 +169,7 @@ module Fiddle
 end unless /mswin|mingw/ =~ RUBY_PLATFORM
 
 def test_dlerror
+  return /kfreebsd/ =~ RUBY_PLATFORM
   # FreeBSD (at least 7.2 to 7.2) calls nsdispatch(3) when it calls
   # getaddrinfo(3). And nsdispatch(3) doesn't call dlerror(3) even if
   # it calls _nss_cache_cycle_prevention_function with dlsym(3).
@@ -177,7 +178,7 @@ module Fiddle
   require 'socket'
   Socket.gethostbyname("localhost")
   Fiddle.dlopen("/lib/libc.so.7").sym('strcpy')
-end if /freebsd/=~ RUBY_PLATFORM
+end if /freebsd/ =~ RUBY_PLATFORM
 
 def test_no_memory_leak
   assert_no_memory_leak(%w[-W0 -rfiddle.so], '', '100_000.times {Fiddle::Handle.allocate}; GC.start', rss: true)
Index: ruby2.5-2.5.1/test/socket/test_socket.rb
===
--- ruby2.5-2.5.1.orig/test/socket/test_socket.rb
+++ ruby2.5-2.5.1/test/socket/test_socket.rb
@@ -507,7 +507,7 @@ class TestSocket < Test::Unit::TestCase
   end
 
   def test_bintime
-return if /freebsd/ !~ RUBY_PLATFORM
+return if /freebsd/ !~ RUBY_PLATFORM || /kfreebsd/ =~ RUBY_PLATFORM
 t1 = Time.now.strftime("%Y-%m-%d")
 stamp = nil
 Addrinfo.udp("127.0.0.1", 0).bind {|s1|