File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 22
22
23
23
#include "j9.h"
24
24
#include "util_internal.h"
25
+ #include <stdint.h>
25
26
26
27
/* there is no error checking: the signature MUST be well-formed */
27
28
UDATA
@@ -30,21 +31,25 @@ getSendSlotsFromSignature(const U_8* signature)
30
31
UDATA sendArgs = 0 ;
31
32
UDATA i = 1 ; /* 1 to skip the opening '(' */
32
33
33
- for (; ; i ++ ) {
34
+ /* All UTF8 in the class file have a size represented by uint16_t. The size check
35
+ * is only necessary for ASGCT where the signature provided may not be valid,
36
+ * but is harmless in the normal runtime case.
37
+ */
38
+ for (; i <= UINT16_MAX ; i ++ ) {
34
39
switch (signature [i ]) {
35
40
case ')' :
36
- return sendArgs ;
41
+ goto done ;
37
42
case '[' :
38
43
/* skip all '['s */
39
- for (i ++ ; signature [i ] == '[' ; i ++ );
44
+ for (i ++ ; ( i <= UINT16_MAX ) && ( signature [i ] == '[' ) ; i ++ );
40
45
if (signature [i ] == 'L' ) {
41
46
/* FALL THRU */
42
47
} else {
43
48
sendArgs ++ ;
44
49
break ;
45
50
}
46
51
case 'L' :
47
- for (i ++ ; signature [i ] != ';' ; i ++ );
52
+ for (i ++ ; ( i <= UINT16_MAX ) && ( signature [i ] != ';' ) ; i ++ );
48
53
sendArgs ++ ;
49
54
break ;
50
55
case 'D' :
@@ -57,5 +62,7 @@ getSendSlotsFromSignature(const U_8* signature)
57
62
break ;
58
63
}
59
64
}
65
+ done :
66
+ return sendArgs ;
60
67
}
61
68
You can’t perform that action at this time.
0 commit comments