Package: libbfio / 20140105-2

01-fix-FTBFS-hurd-386.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Index: libbfio/libcpath/libcpath_path.c
===================================================================
--- libbfio.orig/libcpath/libcpath_path.c
+++ libbfio/libcpath/libcpath_path.c
@@ -338,40 +338,12 @@ int libcpath_path_get_current_working_di
 
 		return( -1 );
 	}
-	*current_working_directory_size = (size_t) PATH_MAX;
-
-	*current_working_directory = libcstring_narrow_string_allocate(
-	                              *current_working_directory_size );
 
+	*current_working_directory = getcwd(
+					    NULL,
+					    0 );
 	if( *current_working_directory == NULL )
 	{
-		libcerror_error_set(
-		 error,
-		 LIBCERROR_ERROR_DOMAIN_MEMORY,
-		 LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
-		 "%s: unable to create current working directory.",
-		 function );
-
-		goto on_error;
-	}
-	if( memory_set(
-	     *current_working_directory,
-	     0,
-	     sizeof( char ) * *current_working_directory_size ) == NULL )
-	{
-		libcerror_error_set(
-		 error,
-		 LIBCERROR_ERROR_DOMAIN_MEMORY,
-		 LIBCERROR_MEMORY_ERROR_SET_FAILED,
-		 "%s: unable to clear current working directory.",
-		 function );
-
-		goto on_error;
-	}
-	if( getcwd(
-	     *current_working_directory,
-	     *current_working_directory_size ) == NULL )
-	{
 		libcerror_system_set_error(
 		 error,
 		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
@@ -382,6 +354,8 @@ int libcpath_path_get_current_working_di
 
 		goto on_error;
 	}
+	*current_working_directory_size = 1 + libcstring_narrow_string_length(
+									      *current_working_directory );
 	return( 1 );
 
 on_error:
@@ -3036,23 +3010,10 @@ int libcpath_path_get_current_working_di
 
 		return( -1 );
 	}
-	narrow_current_working_directory = libcstring_narrow_string_allocate(
-	                                    PATH_MAX );
-
-	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 )
+	narrow_current_working_directory = getcwd(
+						  NULL,
+						  0 );
+	if( narrow_current_working_directory == NULL)
 	{
 		libcerror_system_set_error(
 		 error,