Jelajahi Sumber

If the max section size is less then the read size, return INVALID_PARAM.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1126 fd59a12c-fef9-0310-b244-a6a79926bd2f
Steven Dake 19 tahun lalu
induk
melakukan
3cde5246a6
1 mengubah file dengan 18 tambahan dan 11 penghapusan
  1. 18 11
      exec/ckpt.c

+ 18 - 11
exec/ckpt.c

@@ -3186,30 +3186,37 @@ static void message_handler_req_exec_ckpt_sectionread (
 	}
 
 	/*
-	 * Determine the section size
+	 * If data size is greater then max section size, return INVALID_PARAM
 	 */
-	section_size = checkpoint_section->section_descriptor.section_size -
-		req_exec_ckpt_sectionread->data_offset;
+	if (checkpoint->checkpoint_creation_attributes.max_section_size < 
+		req_exec_ckpt_sectionread->data_size) {
 
-	/*
-	 * If the library has less space available then can be sent from the
-	 * section, reduce bytes sent to library to max requested
-	 */
-	if (section_size < req_exec_ckpt_sectionread->data_size) {
-		section_size = 0;
 		error = SA_AIS_ERR_INVALID_PARAM;
 		goto error_exit;
 	}
 
 	/*
-	 * If data_offset is past end of data, return INVALID PARAM
+	 * If data_offset is past end of data, return INVALID_PARAM
 	 */
 	if (req_exec_ckpt_sectionread->data_offset > checkpoint_section->section_descriptor.section_size) {
-		section_size = 0;
 		error = SA_AIS_ERR_INVALID_PARAM;
 		goto error_exit;
 	}
 
+	/*
+	 * Determine the section size
+	 */
+	section_size = checkpoint_section->section_descriptor.section_size -
+		req_exec_ckpt_sectionread->data_offset;
+
+	/*
+	 * If the library has less space available then can be sent from the
+	 * section, reduce bytes sent to library to max requested
+	 */
+	if (section_size > req_exec_ckpt_sectionread->data_size) {
+		section_size = req_exec_ckpt_sectionread->data_size;
+	}
+
 	/*
 	 * Write read response to CKPT library
 	 */