diff packet.c @ 1610:96e4c9b2cc00 coverity

merge coverity
author Matt Johnston <matt@ucc.asn.au>
date Wed, 21 Mar 2018 00:52:02 +0800
parents 8f7b6f75aa58
children a3bb8f8949de
line wrap: on
line diff
--- a/packet.c	Sun Mar 04 15:07:09 2018 +0800
+++ b/packet.c	Wed Mar 21 00:52:02 2018 +0800
@@ -364,9 +364,11 @@
 
 #if DROPBEAR_FUZZ
 	if (fuzz.fuzzing) {
-		/* fail 1 in 2000 times to test error path.
-		   note that mac_bytes is all zero prior to kex, so don't test ==0 ! */
-		unsigned int value = *((unsigned int*)&mac_bytes);
+	 	/* fail 1 in 2000 times to test error path. */
+		unsigned int value = 0;
+		if (mac_size > sizeof(value)) {
+			memcpy(&value, mac_bytes, sizeof(value));
+		}
 		if (value % 2000 == 99) {
 			return DROPBEAR_FAILURE;
 		}