Source: ruby-posix-spawn
Version: 0.3.8-1
Severity: important
Tags: patch
User: [email protected]
Usertags: hurd

Hi,

Currently the latest version of ruby-posix-spawn fails to build from
source and is flagged as out-of-date. This is due to usage of PATH_MAX,
which is not defined on GNU/Hurd. The attached patch solve this problem by
dynamically allocating space for the string 'error_context' in function
rb_posixspawn_pspawn() of ext/posix-spawn.c.

Thanks!



Index: ruby-posix-spawn-0.3.8/ext/posix-spawn.c
===================================================================
--- ruby-posix-spawn-0.3.8.orig/ext/posix-spawn.c
+++ ruby-posix-spawn-0.3.8/ext/posix-spawn.c
@@ -438,8 +438,12 @@ rb_posixspawn_pspawn(VALUE self, VALUE e
 	}
 
 	if (ret != 0) {
-		char error_context[PATH_MAX+32];
-		snprintf(error_context, sizeof(error_context), "when spawning '%s'", file);
+		char *error_context = NULL;
+		size_t len = 15 + strlen(file) + 1 + 1;
+		error_context = malloc(len);
+		if (error_context == NULL)
+		  return -1;
+		snprintf(error_context, len, "when spawning '%s'", file);
 		errno = ret;
 		rb_sys_fail(error_context);
 	}

Reply via email to