Source: libbfio
Version: 20130507-1
Severity: important
Tags: patch
User: [email protected]
Usertags: hurd

Hello,

libbfio fails to build from source due to usage of PATH_MAX,which is not
defined on GNU/Hurd. The attached patch fixes usage of PATH_MAX as
second argument to getcwd() by using calls to getcwd (NULL, 0) instead.
Supporting (NULL, 0) as arguments is an extension to POSIX.1-2001 for
libc4, libc5 and glibc, so most modern systems have it. In order to
simplify the patch, only this version is implemented.

In case there is a need for a dual code path this can be fixed to, at
the cost of additional #ifdef's in the code and a configure.ac check for
the getcwd (NULL, 0) functionality.

Note also that with the patch applied, the package needs to build-depend
on quilt.

The failure of this package to build blocks the build of e.g. libewf,
libpff and dff, and libewf is flagged as out-of-date since a long time
by now for Hurd.

Thanks! 
Index: libbfio-20130507/libcpath/libcpath_path.c
===================================================================
--- libbfio-20130507.orig/libcpath/libcpath_path.c
+++ libbfio-20130507/libcpath/libcpath_path.c
@@ -356,9 +356,6 @@ int libcpath_path_get_current_working_di
 	}
 #if defined( WINAPI )
 	*current_working_directory_size = (size_t) _MAX_PATH;
-#else
-	*current_working_directory_size = (size_t) PATH_MAX;
-#endif
 	*current_working_directory = libcstring_narrow_string_allocate(
 	                              *current_working_directory_size );
 
@@ -387,7 +384,6 @@ int libcpath_path_get_current_working_di
 
 		goto on_error;
 	}
-#if defined( WINAPI )
 	if( _getcwd(
 	     *current_working_directory,
 	     *current_working_directory_size ) == NULL )
@@ -403,9 +399,8 @@ int libcpath_path_get_current_working_di
 		goto on_error;
 	}
 #else
-	if( getcwd(
-	     *current_working_directory,
-	     *current_working_directory_size ) == NULL )
+	*current_working_directory = getcwd (NULL, 0);
+	if( current_working_directory == NULL )
 	{
 		libcerror_system_set_error(
 		 error,
@@ -417,6 +412,8 @@ int libcpath_path_get_current_working_di
 
 		goto on_error;
 	}
+	*current_working_directory_size = 1 + libcstring_narrow_string_length(
+	                                             *current_working_directory );
 #endif
 	return( 1 );
 
@@ -3113,9 +3110,7 @@ int libcpath_path_get_current_working_di
 #if defined( WINAPI )
 	*current_working_directory_size = (size_t) _MAX_PATH;
 #else
-	narrow_current_working_directory = libcstring_narrow_string_allocate(
-	                                    PATH_MAX );
-
+	narrow_current_working_directory = getcwd (NULL, 0);
 	if( narrow_current_working_directory == NULL )
 	{
 		libcerror_error_set(
@@ -3126,20 +3121,6 @@ int libcpath_path_get_current_working_di
 		 function );
 
 		goto on_error;
-	}
-	if( getcwd(
-	     narrow_current_working_directory,
-	     PATH_MAX ) == NULL )
-	{
-		libcerror_system_set_error(
-		 error,
-		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
-		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
-		 errno,
-		 "%s: unable to retrieve current working directory.",
-		 function );
-
-		goto on_error;
 	}
 	narrow_current_working_directory_size = 1 + libcstring_narrow_string_length(
 	                                             narrow_current_working_directory );

Reply via email to