pvm (3.4.5-12.3) 22-fix_FTBFS4hurd.patch

Summary

 src/pvmd.c |   26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

    
download this patch

Patch contents

Index: pvm-3.4.5+nmu/src/pvmd.c
===================================================================
--- pvm-3.4.5+nmu.orig/src/pvmd.c	2011-08-19 21:06:13.000000000 +0000
+++ pvm-3.4.5+nmu/src/pvmd.c	2011-08-19 21:22:43.000000000 +0000
@@ -3836,7 +3836,8 @@
 	int pid;				/* task pid */
 	int pfd[2];				/* pipe back from task */
 	struct task *tp;		/* new task context */
-	char path[MAXPATHLEN];
+	char *path = NULL, *new_path;
+	size_t path_size = 0, needed_size;
 	struct stat sb;
 	char **ep, **eplist;
 	int i;
@@ -3868,6 +3869,24 @@
 	eplist = CINDEX(name, '/') ? nullep : epaths;
 
 	for (ep = eplist; *ep; ep++) {
+		needed_size = strlen(*ep) + 1;
+		if ((*ep)[0])
+			needed_size++;
+		needed_size += strlen(name);
+#ifdef IMA_OS2
+		needed_size += 4;
+#endif
+		if (path_size < needed_size) {
+			path_size += needed_size;
+			new_path = realloc(path, path_size);
+			if (!new_path) {
+				pvmlogerror("cannot allocate memory\n");
+				free(path);
+				task_free(tp);
+				return PvmOutOfRes;
+			}
+			path = new_path;
+		}
 		(void)strcpy(path, *ep);
 		if (path[0])
 			(void)strcat(path, "/");
@@ -3939,12 +3958,14 @@
 			if (socketpair(AF_UNIX, SOCK_STREAM, 0, pfd) == -1) {
 				pvmlogperror("forkexec() socketpair");
 				task_free(tp);
+				free (path);
 				return PvmOutOfRes;
 			}
 #else
 			if (pipe(pfd) == -1) {
 				pvmlogperror("forkexec() pipe");
 				task_free(tp);
+				free (path);
 				return PvmOutOfRes;
 			}
 #endif
@@ -4077,6 +4098,7 @@
 				(void)close(pfd[0]);
 				(void)close(pfd[1]);
 				task_free(tp);
+				free (path);
 				return PvmOutOfRes;
 			}
 			(void)close(pfd[1]);
@@ -4094,12 +4116,14 @@
 
 		tp->t_a_out = STRALLOC(name);
 		*tpp = tp;
+		free (path);
 		return 0;
 	}
 	if (pvmdebmask & PDMTASK) {
 		pvmlogprintf("forkexec() didn't find <%s>\n", name);
 	}
 	task_free(tp);
+	free (path);
 	return PvmNoFile;
 }