Просмотр исходного кода

defect 633
saCkptInitialize crashes if callbacks parameter is null

(Logical change 1.214)


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

Steven Dake 20 лет назад
Родитель
Сommit
d67705ec20
1 измененных файлов с 9 добавлено и 1 удалено
  1. 9 1
      lib/ckpt.c

+ 9 - 1
lib/ckpt.c

@@ -197,7 +197,11 @@ saCkptInitialize (
 		goto error_put_destroy;
 		goto error_put_destroy;
 	}
 	}
 
 
-	memcpy (&ckptInstance->callbacks, callbacks, sizeof (SaCkptCallbacksT));
+	if (callbacks) {
+		memcpy (&ckptInstance->callbacks, callbacks, sizeof (SaCkptCallbacksT));
+	} else {
+		memset (&ckptInstance->callbacks, 0, sizeof (SaCkptCallbacksT));
+	}
 
 
 	list_init (&ckptInstance->checkpoint_list);
 	list_init (&ckptInstance->checkpoint_list);
 
 
@@ -318,6 +322,7 @@ saCkptDispatch (
 				goto error_unlock;
 				goto error_unlock;
 			}
 			}
 		}
 		}
+
 		/*
 		/*
 		* Make copy of callbacks, message data, unlock instance,
 		* Make copy of callbacks, message data, unlock instance,
 		* and call callback. A risk of this dispatch method is that
 		* and call callback. A risk of this dispatch method is that
@@ -331,6 +336,9 @@ saCkptDispatch (
 		 */
 		 */
 		switch (dispatch_data.header.id) {
 		switch (dispatch_data.header.id) {
 		case MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPENASYNC:
 		case MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPENASYNC:
+			if (callbacks.saCkptCheckpointOpenCallback == NULL) {
+				continue;
+			}
 			res_lib_ckpt_checkpointopenasync = (struct res_lib_ckpt_checkpointopenasync *) &dispatch_data;
 			res_lib_ckpt_checkpointopenasync = (struct res_lib_ckpt_checkpointopenasync *) &dispatch_data;
 
 
 			/*
 			/*