瀏覽代碼

This patch checks the result of read operations on a socket which can
return errors or 0. Now if those cases happen, the operation is
ignored. This part of the code needs more attention later to handle
short reads. This removes a warning when fortify source is defined to
the compiler.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1053 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake 20 年之前
父節點
當前提交
7805cb474d
共有 1 個文件被更改,包括 12 次插入2 次删除
  1. 12 2
      lcr/uis.c

+ 12 - 2
lcr/uis.c

@@ -122,9 +122,19 @@ static void lcr_uis_dispatch (int fd)
 {
 	struct req_msg header;
 	char msg_contents[512];
+	ssize_t readsize;
 
-	read (fd, &header, sizeof (header));
-	read (fd, msg_contents, sizeof (msg_contents));
+	/*
+	 * TODO this doesn't handle short reads
+	 */
+	readsize = read (fd, &header, sizeof (header));
+	if (readsize == -1) {
+		return;
+	}
+	readsize = read (fd, msg_contents, sizeof (msg_contents));
+	if (readsize == -1) {
+		return;
+	}
 
 	printf ("msg contents %s\n", msg_contents);
 }