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

Bug#748653: dateutils: FTBFS on hurd-i386



Source: dateutils
Version: 2.7-1
Severity: important
Tags: patch
User: debian-hurd@lists.debian.org
Usertags: hurd

Hi,

Currently dateutils fails to build from source on GNU/Hurd due to
PATH_MAX being used, and that constant is not defined. The attached
patch avoid using PATH_MAX by redefining the function mkfifofn() to
allocate and return the string buf there and free the allocated buffers
expfn and actfn in the calling function differ() when not needed any
longer.

All 610 tests run in the testsuite pass and they are a requisite for the
package to build. Selected tests have also been run with valgind under
GNU/Linux with no errors or memory leaks.

Thanks!
--- a/test/clittool.c
+++ b/test/clittool.c
@@ -619,11 +619,15 @@ xclosefrom(int fd)
 	return;
 }
 
-static void
-mkfifofn(char *restrict buf, size_t bsz, const char *key, unsigned int tid)
+static char*
+mkfifofn(const char *key, unsigned int tid)
 {
-	snprintf(buf, bsz, "%s output  %x", key, tid);
-	return;
+	char  *buf = NULL;
+	size_t len = strlen(key) + 9 + 8 + 1;
+	buf = malloc(len);
+	if (buf)
+		snprintf(buf, len, "%s output  %x", key, tid);
+	return buf;
 }
 
 static pid_t
@@ -670,23 +674,27 @@ differ(struct clit_chld_s ctx[static 1],
 #if !defined L_tmpnam
 # define L_tmpnam	(PATH_MAX)
 #endif	/* !L_tmpnam */
-	static char expfn[PATH_MAX];
-	static char actfn[PATH_MAX];
+	char *expfn = NULL;
+	char *actfn = NULL;
 	pid_t difftool = -1;
 
 	assert(!clit_bit_fd_p(exp));
 
-	if (clit_bit_fn_p(exp) &&
-	    (strlen(exp.d) >= sizeof(expfn) || strcpy(expfn, exp.d) == NULL)) {
-		error("cannot prepare in file `%s'", exp.d);
-		goto out;
-	} else if (!clit_bit_fn_p(exp) &&
-		   (mkfifofn(expfn, sizeof(expfn), "expected", ctx->test_id),
-		    mkfifo(expfn, 0666) < 0)) {
-		error("cannot create fifo `%s'", expfn);
-		goto out;
-	} else if (mkfifofn(actfn, sizeof(actfn), "actual", ctx->test_id),
-		   mkfifo(actfn, 0666) < 0) {
+	if (clit_bit_fn_p(exp)) {
+		expfn = malloc(strlen(exp.d) + 1);
+		if (expfn == NULL || strcpy(expfn, exp.d) == NULL) {
+			error("cannot prepare in file `%s'", exp.d);
+			goto out;
+		}
+	} else {
+		expfn = mkfifofn("expected", ctx->test_id);
+		if (expfn == NULL || mkfifo(expfn, 0666) < 0) {
+			error("cannot create fifo `%s'", expfn);
+			goto out;
+		}
+	}
+	actfn = mkfifofn("actual", ctx->test_id);
+	if (actfn == NULL || mkfifo(actfn, 0666) < 0) {
 		error("cannot create fifo `%s'", actfn);
 		goto out;
 	}
@@ -701,7 +709,7 @@ differ(struct clit_chld_s ctx[static 1],
 
 	case 0:;
 		/* i am the child */
-		static char *const diff_opt[] = {
+		char *const diff_opt[] = {
 			"diff",
 			"-u",
 			expfn, actfn, NULL,
@@ -761,11 +769,14 @@ differ(struct clit_chld_s ctx[static 1],
 
 	unblock_sigs();
 out:
-	if (*expfn && !clit_bit_fn_p(exp)) {
-		unlink(expfn);
+	if (expfn) {
+		if (!clit_bit_fn_p(exp))
+			unlink(expfn);
+		free(expfn);
 	}
-	if (*actfn) {
+	if (actfn) {
 		unlink(actfn);
+		free(actfn);
 	}
 	return difftool;
 }

Reply to: