Package: libedit
Version: 2.11~20080614-1
Severity: normal
Tags: patch
User: [EMAIL PROTECTED]
Usertags: origin-ubuntu intrepid ubuntu-patch

Hello!  Attached is a patch to fix the lack of error-checking for 2
write() calls, as discovered when compiling with -D_FORTIFY_SOURCE=2.

Thanks!

-- 
Kees Cook                                            @outflux.net
Index: libedit-2.11~20080614/libedit/vi.c
===================================================================
--- libedit-2.11~20080614.orig/libedit/vi.c	2008-06-28 17:57:32.000000000 -0700
+++ libedit-2.11~20080614/libedit/vi.c	2008-06-28 17:59:14.000000000 -0700
@@ -1012,8 +1012,12 @@
 	if (fd < 0)
 		return CC_ERROR;
 	cp = el->el_line.buffer;
-	write(fd, cp, el->el_line.lastchar - cp +0u);
-	write(fd, "\n", 1);
+	if (write(fd, cp, el->el_line.lastchar - cp +0u)<0 ||
+	    write(fd, "\n", 1)<0) {
+		close(fd);
+		unlink(tempfile);
+		return CC_ERROR;
+	}
 	pid = fork();
 	switch (pid) {
 	case -1:

Reply via email to