]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - lib/asn1_decoder.c
x86/speculation: Rework speculative_store_bypass_update()
[mirror_ubuntu-artful-kernel.git] / lib / asn1_decoder.c
index 554522934c442ae15c01b1b1266e8e3e9515bfbd..1ef0cec38d7879332966f8095d0bfdc0c7580230 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/export.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
+#include <linux/module.h>
 #include <linux/asn1_decoder.h>
 #include <linux/asn1_ber_bytecode.h>
 
@@ -227,7 +228,7 @@ next_op:
                hdr = 2;
 
                /* Extract a tag from the data */
-               if (unlikely(dp >= datalen - 1))
+               if (unlikely(datalen - dp < 2))
                        goto data_overrun_error;
                tag = data[dp++];
                if (unlikely((tag & 0x1f) == ASN1_LONG_TAG))
@@ -273,7 +274,7 @@ next_op:
                                int n = len - 0x80;
                                if (unlikely(n > 2))
                                        goto length_too_long;
-                               if (unlikely(dp >= datalen - n))
+                               if (unlikely(n > datalen - dp))
                                        goto data_overrun_error;
                                hdr += n;
                                for (len = 0; n > 0; n--) {
@@ -283,6 +284,9 @@ next_op:
                                if (unlikely(len > datalen - dp))
                                        goto data_overrun_error;
                        }
+               } else {
+                       if (unlikely(len > datalen - dp))
+                               goto data_overrun_error;
                }
 
                if (flags & FLAG_CONS) {
@@ -506,3 +510,5 @@ error:
        return -EBADMSG;
 }
 EXPORT_SYMBOL_GPL(asn1_ber_decoder);
+
+MODULE_LICENSE("GPL");