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

Hello,

libpff 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.

libpff does not build on Hurd but with the PATH_MAX fix of libbfio in
bug #754792 and this patch it will.

Note: This patch is almost identical to the one in libewf: #754816 and
parts of libbfio: #754792

Thanks! 


Index: libpff-20120802/libcpath/libcpath_path.c
===================================================================
--- libpff-20120802.orig/libcpath/libcpath_path.c
+++ libpff-20120802/libcpath/libcpath_path.c
@@ -342,12 +342,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 );
 
@@ -362,7 +356,6 @@ int libcpath_path_get_current_working_di
 
 		goto on_error;
 	}
-#if defined( WINAPI )
 	if( _getcwd(
 	     *current_working_directory,
 	     *current_working_directory_size ) == NULL )
@@ -378,9 +371,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,
@@ -392,6 +386,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 );
 
@@ -3048,24 +3044,11 @@ int libcpath_path_get_current_working_di
 	*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