Package: ctdb
Version: 1.0.112-12-1
Severity: normal
Tags: patch
Justification: Policy 9.3.2
User: [email protected]
Usertags: origin-ubuntu natty ubuntu-patch

Hello,

In Ubuntu we applied the following changes:

- debian/patches/99-fix-gcc-warnings: Hide gcc warnings.
- debian/patches/99-fix-broken-readdir-test.diff: Fix broken readdir
  test.

And we think you might be interested in applying them too, attaching the
patches.
diff -Naurp ctdb-1.0.108.orig/lib/events/events_signal.c ctdb-1.0.108/lib/events/events_signal.c
--- ctdb-1.0.108.orig/lib/events/events_signal.c	2009-12-10 09:31:41.000000000 -0500
+++ ctdb-1.0.108/lib/events/events_signal.c	2010-01-12 11:13:28.112386323 -0500
@@ -216,7 +216,8 @@ struct signal_event *common_event_add_si
 	if (ev->pipe_fde == NULL) {
 		if (sig_state->pipe_hack[0] == 0 && 
 		    sig_state->pipe_hack[1] == 0) {
-			pipe(sig_state->pipe_hack);
+			if (pipe(sig_state->pipe_hack)) 
+				return;
 			set_blocking(sig_state->pipe_hack[0], False);
 			set_blocking(sig_state->pipe_hack[1], False);
 		}
diff -Naurp ctdb-1.0.108.orig/lib/replace/getpass.c ctdb-1.0.108/lib/replace/getpass.c
--- ctdb-1.0.108.orig/lib/replace/getpass.c	2009-12-10 09:31:41.000000000 -0500
+++ ctdb-1.0.108/lib/replace/getpass.c	2010-01-12 11:04:00.202386891 -0500
@@ -185,7 +185,8 @@ char *rep_getpass(const char *prompt)
 	buf[0] = 0;
 	if (!gotintr) {
 		in_fd = fileno(in);
-		fgets(buf, bufsize, in);
+		if (fgets(buf, bufsize, in) != in)
+			return NULL;
 	}
 	nread = strlen(buf);
 	if (nread) {
diff -Naurp ctdb-1.0.108.orig/server/ctdb_lockwait.c ctdb-1.0.108/server/ctdb_lockwait.c
--- ctdb-1.0.108.orig/server/ctdb_lockwait.c	2009-12-10 09:31:42.000000000 -0500
+++ ctdb-1.0.108/server/ctdb_lockwait.c	2010-01-12 10:21:53.441761347 -0500
@@ -137,7 +137,9 @@ struct lockwait_handle *ctdb_lockwait(st
 		char c = 0;
 		close(result->fd[0]);
 		tdb_chainlock(ctdb_db->ltdb->tdb, key);
-		write(result->fd[1], &c, 1);
+		if (write(result->fd[1], &c, 1) != 1) {
+			return NULL;
+		}
 		/* make sure we die when our parent dies */
 		while (kill(parent, 0) == 0 || errno != ESRCH) {
 			sleep(5);
diff -Naurp ctdb-1.0.108.orig/server/ctdb_logging.c ctdb-1.0.108/server/ctdb_logging.c
--- ctdb-1.0.108.orig/server/ctdb_logging.c	2009-12-10 09:31:42.000000000 -0500
+++ ctdb-1.0.108/server/ctdb_logging.c	2010-01-12 10:55:50.402386601 -0500
@@ -263,7 +263,8 @@ static void ctdb_logfile_log(const char 
 	if (ret == -1) {
 		const char *errstr = "vasprintf failed\n";
 
-		write(log_state->fd, errstr, strlen(errstr));
+		if (write(log_state->fd, errstr, strlen(errstr)) != strlen(errstr))
+			return;
 		return;
 	}
 
@@ -277,11 +278,13 @@ static void ctdb_logfile_log(const char 
 	free(s);
 	if (ret == -1) {
 		const char *errstr = "asprintf failed\n";
-		write(log_state->fd, errstr, strlen(errstr));
+		if(write(log_state->fd, errstr, strlen(errstr)) != strlen(errstr))
+			return;
 		return;
 	}
 	if (s2) {
-		write(log_state->fd, s2, strlen(s2));
+		if (write(log_state->fd, s2, strlen(s2)) != strlen(s2))
+			return;
 		free(s2);
 	}
 }
@@ -295,12 +298,14 @@ static void ctdb_logfile_log_add(const c
 	if (ret == -1) {
 		const char *errstr = "vasprintf failed\n";
 
-		write(log_state->fd, errstr, strlen(errstr));
+		if (write(log_state->fd, errstr, strlen(errstr)) != strlen(errstr))
+			return;
 		return;
 	}
 
 	if (s) {
-		write(log_state->fd, s, strlen(s));
+		if (write(log_state->fd, s, strlen(s)) != strlen(s))
+			free(s);
 		free(s);
 	}
 }
diff -Naurp ctdb-1.0.108.orig/server/ctdb_persistent.c ctdb-1.0.108/server/ctdb_persistent.c
--- ctdb-1.0.108.orig/server/ctdb_persistent.c	2009-12-10 09:31:42.000000000 -0500
+++ ctdb-1.0.108/server/ctdb_persistent.c	2010-01-12 10:42:02.171761060 -0500
@@ -458,7 +458,8 @@ struct childwrite_handle *ctdb_childwrit
 			c = 1;
 		}
 
-		write(result->fd[1], &c, 1);
+		if (write(result->fd[1], &c, 1) != 1)
+			return NULL;
 
 		/* make sure we die when our parent dies */
 		while (kill(parent, 0) == 0 || errno != ESRCH) {
diff -Naurp ctdb-1.0.108.orig/server/ctdb_recover.c ctdb-1.0.108/server/ctdb_recover.c
--- ctdb-1.0.108.orig/server/ctdb_recover.c	2009-12-10 09:31:42.000000000 -0500
+++ ctdb-1.0.108/server/ctdb_recover.c	2010-01-12 10:27:38.362386447 -0500
@@ -727,11 +727,13 @@ int32_t ctdb_control_set_recmode(struct 
 			cc = 1;
 		}
 
-		write(state->fd[1], &cc, 1);
+		if (write(state->fd[1], &cc, 1) != 1) 
+			return -1;
 		/* make sure we die when our parent dies */
 		while (kill(parent, 0) == 0 || errno != ESRCH) {
 			sleep(5);
-			write(state->fd[1], &cc, 1);
+			if (write(state->fd[1], &cc, 1) != 1)
+				break;
 		}
 		_exit(0);
 	}
diff -Naurp ctdb-1.0.108.orig/server/ctdb_recoverd.c ctdb-1.0.108/server/ctdb_recoverd.c
--- ctdb-1.0.108.orig/server/ctdb_recoverd.c	2009-12-10 09:31:42.000000000 -0500
+++ ctdb-1.0.108/server/ctdb_recoverd.c	2010-01-12 10:25:15.152386407 -0500
@@ -2617,11 +2617,13 @@ static int check_recovery_lock(struct ct
 			cc = RECLOCK_FAILED;
 		}
 
-		write(state->fd[1], &cc, 1);
+		if (write(state->fd[1], &cc, 1) != 1)
+			return -1;
 		/* make sure we die when our parent dies */
 		while (kill(parent, 0) == 0 || errno != ESRCH) {
 			sleep(5);
-			write(state->fd[1], &cc, 1);
+			if (write(state->fd[1], &cc, 1) != 1)
+				break;
 		}
 		_exit(0);
 	}
diff -Naurp ctdb-1.0.108.orig/server/ctdb_vacuum.c ctdb-1.0.108/server/ctdb_vacuum.c
--- ctdb-1.0.108.orig/server/ctdb_vacuum.c	2009-12-10 09:31:42.000000000 -0500
+++ ctdb-1.0.108/server/ctdb_vacuum.c	2010-01-12 11:03:03.152386512 -0500
@@ -839,7 +839,8 @@ ctdb_vacuum_event(struct event_context *
 		 */
 		cc = ctdb_repack_db(ctdb_db, child_ctx);
 
-		write(child_ctx->fd[1], &cc, 1);
+		if (write(child_ctx->fd[1], &cc, 1) != 1)
+			return;
 		_exit(0);
 	}
 
diff -Naurp ctdb-1.0.108.orig/server/eventscript.c ctdb-1.0.108/server/eventscript.c
--- ctdb-1.0.108.orig/server/eventscript.c	2009-12-10 09:31:42.000000000 -0500
+++ ctdb-1.0.108/server/eventscript.c	2010-01-12 10:41:28.601761072 -0500
@@ -50,7 +50,9 @@ static void sigterm(int sig)
 	strftime(tbuf, sizeof(tbuf)-1, "%Y%m%d%H%M%S", 	localtime(&t));
 	sprintf(buf, "{ pstree -p; cat /proc/locks; ls -li /var/ctdb/ /var/ctdb/persistent; }"
 		" >/tmp/ctdb.event.%s.%d", tbuf, getpid());
-	system(buf);
+	if (system(buf) != -1 ) {
+		printf("system() failed");
+	}
 
 	DEBUG(DEBUG_ERR,("Logged timedout eventscript : %s\n", buf));
 
@@ -407,7 +409,8 @@ static int fork_child_for_script(struct 
 		rt = child_run_script(ctdb, state->from_user, state->call, state->options, current);
 		/* We must be able to write PIPEBUF bytes at least; if this
 		   somehow fails, the read above will be short. */
-		write(state->fd[1], &rt, sizeof(rt));
+		if (write(state->fd[1], &rt, sizeof(rt)) != sizeof(rt))
+			return -errno;
 		close(state->fd[1]);
 		_exit(rt);
 	}
diff -Naurp ctdb-1.0.108.orig/tools/ctdb.c ctdb-1.0.108/tools/ctdb.c
--- ctdb-1.0.108.orig/tools/ctdb.c	2009-12-10 09:31:42.000000000 -0500
+++ ctdb-1.0.108/tools/ctdb.c	2010-01-12 11:19:56.242386360 -0500
@@ -3245,7 +3245,8 @@ static int control_restoredb(struct ctdb
 		return -1;
 	}
 
-	read(fh, &dbhdr, sizeof(dbhdr));
+	if (read(fh, &dbhdr, sizeof(dbhdr)) != sizeof(dbhdr))
+		return -1;
 	if (dbhdr.version != DB_VERSION) {
 		DEBUG(DEBUG_ERR,("Invalid version of database dump. File is version %lu but expected version was %u\n", dbhdr.version, DB_VERSION));
 		talloc_free(tmp_ctx);
@@ -3260,7 +3261,8 @@ static int control_restoredb(struct ctdb
 		talloc_free(tmp_ctx);
 		return -1;
 	}		
-	read(fh, outdata.dptr, outdata.dsize);
+	if (read(fh, outdata.dptr, outdata.dsize) != outdata.dsize)
+		return -1;
 	close(fh);
 
 	tm = localtime(&dbhdr.timestamp);
@@ -3613,7 +3615,10 @@ static int control_dumpmemory(struct ctd
 		talloc_free(tmp_ctx);
 		return -1;
 	}
-	write(1, data.dptr, data.dsize);
+	if (write(1, data.dptr, data.dsize) != data.dsize) {
+		talloc_free(tmp_ctx);
+		return -1;
+	}
 	talloc_free(tmp_ctx);
 	return 0;
 }
@@ -3624,7 +3629,8 @@ static int control_dumpmemory(struct ctd
 static void mem_dump_handler(struct ctdb_context *ctdb, uint64_t srvid, 
 			     TDB_DATA data, void *private_data)
 {
-	write(1, data.dptr, data.dsize);
+	if (write(1, data.dptr, data.dsize) != data.dsize)
+		exit(0);
 	exit(0);
 }
 
diff -Naurp ctdb-1.0.108.orig/configure ctdb-1.0.108/configure
--- ctdb-1.0.108.orig/configure	2009-12-10 09:31:44.000000000 -0500
+++ ctdb-1.0.108/configure	2010-01-12 09:30:45.991761240 -0500
@@ -8139,7 +8139,7 @@ else
 /* end confdefs.h.  */
 
 #define test_readdir_os2_delete main
-#include "$libreplacedir/test/os2_delete.c"
+#include "$libreplacedir/tests/os2_delete.c"
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
   libreplace_cv_READDIR_NEEDED=no
@@ -8273,7 +8273,7 @@ else
 #define _LIBREPLACE_REPLACE_H
 #include "$libreplacedir/repdir_getdirentries.c"
 #define test_readdir_os2_delete main
-#include "$libreplacedir/test/os2_delete.c"
+#include "$libreplacedir/tests/os2_delete.c"
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
   libreplace_cv_READDIR_GETDIRENTRIES=yes
@@ -8334,7 +8334,7 @@ else
 #error _donot_use_getdents_replacement_anymore
 #include "$libreplacedir/repdir_getdents.c"
 #define test_readdir_os2_delete main
-#include "$libreplacedir/test/os2_delete.c"
+#include "$libreplacedir/tests/os2_delete.c"
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
   libreplace_cv_READDIR_GETDENTS=yes
diff -Naurp ctdb-1.0.108.orig/lib/replace/repdir.m4 ctdb-1.0.108/lib/replace/repdir.m4
--- ctdb-1.0.108.orig/lib/replace/repdir.m4	2009-12-10 09:31:41.000000000 -0500
+++ ctdb-1.0.108/lib/replace/repdir.m4	2010-01-12 09:31:17.261761034 -0500
@@ -1,7 +1,7 @@
 AC_CACHE_CHECK([for broken readdir],libreplace_cv_READDIR_NEEDED,[
 	AC_TRY_RUN([
 #define test_readdir_os2_delete main
-#include "$libreplacedir/test/os2_delete.c"],
+#include "$libreplacedir/tests/os2_delete.c"],
 	[libreplace_cv_READDIR_NEEDED=no],
 	[libreplace_cv_READDIR_NEEDED=yes],
 	[libreplace_cv_READDIR_NEEDED="assuming not"])
@@ -34,7 +34,7 @@ AC_CACHE_CHECK([for replacing readdir us
 #define _LIBREPLACE_REPLACE_H
 #include "$libreplacedir/repdir_getdirentries.c"
 #define test_readdir_os2_delete main
-#include "$libreplacedir/test/os2_delete.c"],
+#include "$libreplacedir/tests/os2_delete.c"],
 	[libreplace_cv_READDIR_GETDIRENTRIES=yes],
 	[libreplace_cv_READDIR_GETDIRENTRIES=no])
 ])
@@ -57,7 +57,7 @@ AC_CACHE_CHECK([for replacing readdir us
 #error _donot_use_getdents_replacement_anymore
 #include "$libreplacedir/repdir_getdents.c"
 #define test_readdir_os2_delete main
-#include "$libreplacedir/test/os2_delete.c"],
+#include "$libreplacedir/tests/os2_delete.c"],
 	[libreplace_cv_READDIR_GETDENTS=yes],
 	[libreplace_cv_READDIR_GETDENTS=no])
 ])

Reply via email to