﻿id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc
703,[cpio] Segmentation fault using option -d,bartolomiew,scottmc,"cpio is a tool required to build openjdk.
When compiling, cpio uses the following options: pdum
Using the option 'd' causes a segmentation fault.
I propose the following patch :

{{{
diff -Naur cpio-2.10/configure.ac cpio-2.10-haiku/configure.ac
--- cpio-2.10/configure.ac	2009-06-20 10:28:11.003932160 +0200
+++ cpio-2.10-haiku/configure.ac	2013-03-12 07:18:46.710934528 +0100
@@ -44,6 +44,8 @@
 AC_HEADER_STDC
 AC_HEADER_DIRENT
 
+AC_SEARCH_LIBS(gethostbyname, [socket, network])
+
 AC_CHECK_FUNCS([fchmod fchown])
 # This is needed for mingw build
 AC_CHECK_FUNCS([setmode getpwuid getpwnam getgrgid getgrnam pipe fork getuid geteuid])
diff -Naur cpio-2.10/gnu/hash.c cpio-2.10-haiku/gnu/hash.c
--- cpio-2.10/gnu/hash.c	2009-06-19 11:11:54.017039360 +0200
+++ cpio-2.10-haiku/gnu/hash.c	2013-03-12 07:18:46.715653120 +0100
@@ -491,6 +491,7 @@
 check_tuning (Hash_table *table)
 {
   const Hash_tuning *tuning = table->tuning;
+  float epsilon = 0.1f;
   if (tuning == &default_tuning)
     return true;
 
@@ -499,7 +500,6 @@
      fail to grow or shrink as they should.  The smallest allocation
      is 11 (due to next_prime's algorithm), so an epsilon of 0.1
      should be good enough.  */
-  float epsilon = 0.1f;
 
   if (epsilon < tuning->growth_threshold
       && tuning->growth_threshold < 1 - epsilon
diff -Naur cpio-2.10/src/makepath.c cpio-2.10-haiku/src/makepath.c
--- cpio-2.10/src/makepath.c	2009-02-14 19:15:50.035651584 +0100
+++ cpio-2.10-haiku/src/makepath.c	2013-03-12 07:24:12.562561024 +0100
@@ -56,6 +56,7 @@
   char *dirpath;		/* A copy we can scribble NULs on.  */
   struct stat stats;
   int retval = 0;
+  char *slash;  
   mode_t tmpmode;
   mode_t invert_permissions;
   int we_are_root = getuid () == 0;
@@ -68,7 +69,7 @@
       tmpmode = MODE_RWX & ~ newdir_umask;
       invert_permissions = we_are_root ? 0 : MODE_WXUSR & ~ tmpmode;
 
-      char *slash = dirpath;
+      slash = dirpath;
       while (*slash == '/')
 	slash++;
       while ((slash = strchr (slash, '/')))
}}}
",defect,closed,normal,,app-arch/cpio,,blocker,fixed,,
