Browse Source

Merge branch 'fixes-v4.14-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security

Pull key handling fix from James Morris:
 "Fix by Eric Biggers for the keys subsystem"

* 'fixes-v4.14-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
  KEYS: fix NULL pointer dereference during ASN.1 parsing [ver #2]
Linus Torvalds 7 years ago
parent
commit
d6a2cf07f0
1 changed files with 2 additions and 2 deletions
  1. 2 2
      lib/asn1_decoder.c

+ 2 - 2
lib/asn1_decoder.c

@@ -228,7 +228,7 @@ next_op:
 		hdr = 2;
 		hdr = 2;
 
 
 		/* Extract a tag from the data */
 		/* Extract a tag from the data */
-		if (unlikely(dp >= datalen - 1))
+		if (unlikely(datalen - dp < 2))
 			goto data_overrun_error;
 			goto data_overrun_error;
 		tag = data[dp++];
 		tag = data[dp++];
 		if (unlikely((tag & 0x1f) == ASN1_LONG_TAG))
 		if (unlikely((tag & 0x1f) == ASN1_LONG_TAG))
@@ -274,7 +274,7 @@ next_op:
 				int n = len - 0x80;
 				int n = len - 0x80;
 				if (unlikely(n > 2))
 				if (unlikely(n > 2))
 					goto length_too_long;
 					goto length_too_long;
-				if (unlikely(dp >= datalen - n))
+				if (unlikely(n > datalen - dp))
 					goto data_overrun_error;
 					goto data_overrun_error;
 				hdr += n;
 				hdr += n;
 				for (len = 0; n > 0; n--) {
 				for (len = 0; n > 0; n--) {