projects
/
firefly-linux-kernel-4.4.55.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
drm: bridge: dw-hdmi: optimize edid reading process
[firefly-linux-kernel-4.4.55.git]
/
lib
/
asn1_decoder.c
diff --git
a/lib/asn1_decoder.c
b/lib/asn1_decoder.c
index 2b3f46c049d458a590d080823b344da3b3229f7c..554522934c442ae15c01b1b1266e8e3e9515bfbd 100644
(file)
--- a/
lib/asn1_decoder.c
+++ b/
lib/asn1_decoder.c
@@
-74,7
+74,7
@@
next_tag:
/* Extract a tag from the data */
tag = data[dp++];
/* Extract a tag from the data */
tag = data[dp++];
- if (tag ==
0
) {
+ if (tag ==
ASN1_EOC
) {
/* It appears to be an EOC. */
if (data[dp++] != 0)
goto invalid_eoc;
/* It appears to be an EOC. */
if (data[dp++] != 0)
goto invalid_eoc;
@@
-96,10
+96,8
@@
next_tag:
/* Extract the length */
len = data[dp++];
/* Extract the length */
len = data[dp++];
- if (len <= 0x7f) {
- dp += len;
- goto next_tag;
- }
+ if (len <= 0x7f)
+ goto check_length;
if (unlikely(len == ASN1_INDEFINITE_LENGTH)) {
/* Indefinite length */
if (unlikely(len == ASN1_INDEFINITE_LENGTH)) {
/* Indefinite length */
@@
-110,14
+108,18
@@
next_tag:
}
n = len - 0x80;
}
n = len - 0x80;
- if (unlikely(n > sizeof(
size_t
) - 1))
+ if (unlikely(n > sizeof(
len
) - 1))
goto length_too_long;
if (unlikely(n > datalen - dp))
goto data_overrun_error;
goto length_too_long;
if (unlikely(n > datalen - dp))
goto data_overrun_error;
- for (len = 0; n > 0; n--) {
+ len = 0;
+ for (; n > 0; n--) {
len <<= 8;
len |= data[dp++];
}
len <<= 8;
len |= data[dp++];
}
+check_length:
+ if (len > datalen - dp)
+ goto data_overrun_error;
dp += len;
goto next_tag;
dp += len;
goto next_tag;