[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#933015: libssh FTBFS on hurd: unconditional usage of PATH_MAX



Package: src:libssh
Severity: Important
Version: 0.9.0-1
Tags: patch
User: debian-hurd@lists.debian.org
Usertags: hurd
X-Debbugs-CC: debian-hurd@lists.debian.org

Dear maintainer,

the package libssh fails to build from source on hurd-i386 in sid due
to an unconditional use of PATH_MAX, which the Hurd does not provide.

A patch which uses code similiar to the example in [1] is appended.

Thanks

[1]: 
https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html
Subject: Fix unconditional use of PATH_MAX
Author: Paul Sonnenschein <paul@sonnenschein.ruhr>
diff --git a/tests/torture.c b/tests/torture.c
index 772942c..8f9f39d 100644
--- a/tests/torture.c
+++ b/tests/torture.c
@@ -1029,17 +1029,25 @@ char *torture_get_current_working_dir(void)
 
     char *cwd = NULL;
     char *result = NULL;
+    size_t path_max;
+
+#ifdef PATH_MAX
+    path_max = PATH_MAX;
+#else
+    path_max = 4095;
+#endif /* PATH_MAX undefined */
+    for ( ; result == NULL; path_max *= 2) {
+        cwd = (char *)realloc(cwd, path_max + 1);
+        if (cwd == NULL) {
+            goto end;
+        }
 
-    cwd = (char *)malloc(PATH_MAX + 1);
-    if (cwd == NULL) {
-        goto end;
-    }
-
-    result = getcwd(cwd, PATH_MAX);
+        result = getcwd(cwd, path_max);
 
-    if (result == NULL) {
-        SAFE_FREE(cwd);
-        goto end;
+        if (result == NULL && errno != ERANGE) {
+            SAFE_FREE(cwd);
+            goto end;
+        }
     }
 
 end:

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: