Source: libewf
Version: 20130416-3
Severity: important
Tags: patch
User: [email protected]
Usertags: hurd

Hello,

libewf 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 too, at
the cost of additional #ifdef's in the code and a configure.ac check for
the getcwd (NULL, 0) functionality.

libewf is flagged as out-of-date since a long time by now for Hurd and
with the PATH_MAX fix of libbfio in bug #754792 and this patch it will
be up-to-date again.

Thanks! 

Index: libewf-20130416/libcpath/libcpath_path.c
===================================================================
--- libewf-20130416.orig/libcpath/libcpath_path.c
+++ libewf-20130416/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,10 @@ 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 +414,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 );
 
@@ -3108,24 +3107,11 @@ 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(
-		 error,
-		 LIBCERROR_ERROR_DOMAIN_MEMORY,
-		 LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
-		 "%s: unable to create narrow current working directory.",
-		 function );
-
-		goto on_error;
-	}
-	if( getcwd(
-	     narrow_current_working_directory,
-	     PATH_MAX ) == NULL )
-	{
 		libcerror_system_set_error(
 		 error,
 		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
_______________________________________________
forensics-devel mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/forensics-devel

Reply via email to