Explorar o código

merge trunk revision 2823:
r2823 | asalkeld | 2010-05-13 19:03:49 -0700 (Thu, 13 May 2010) | 2 lines

cov 10379 &10380: check result of open before calling ftruncate.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/branches/flatiron@2866 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake %!s(int64=15) %!d(string=hai) anos
pai
achega
152fe318fa
Modificáronse 1 ficheiros con 6 adicións e 4 borrados
  1. 6 4
      exec/coroipcs.c

+ 6 - 4
exec/coroipcs.c

@@ -263,8 +263,9 @@ memory_map (
 
 
 	unlink (path);
 	unlink (path);
 
 
-	res = ftruncate (fd, bytes);
-
+	if (fd >= 0) {
+		res = ftruncate (fd, bytes);
+	}
 	addr_orig = mmap (NULL, bytes, PROT_NONE,
 	addr_orig = mmap (NULL, bytes, PROT_NONE,
 		MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
 		MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
 
 
@@ -305,8 +306,9 @@ circular_memory_map (
 
 
 	unlink (path);
 	unlink (path);
 
 
-	res = ftruncate (fd, bytes);
-
+	if (fd >= 0) {
+		res = ftruncate (fd, bytes);
+	}
 	addr_orig = mmap (NULL, bytes << 1, PROT_NONE,
 	addr_orig = mmap (NULL, bytes << 1, PROT_NONE,
 		MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
 		MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);