JVM
|
#include "validity.h"
#include "constantpool.h"
#include "utf8.h"
#include "readfunctions.h"
#include <locale.h>
#include <wctype.h>
#include <ctype.h>
Functions | |
char | checkMethodAccessFlags (JavaClass *jc, uint16_t accessFlags) |
Checks whether the "accessFlags" parameter has a valid combination of method flags. More... | |
char | checkFieldAccessFlags (JavaClass *jc, uint16_t accessFlags) |
Checks whether the "accessFlags" parameter has a valid combination of field flags. More... | |
char | checkClassIndexAndAccessFlags (JavaClass *jc) |
Verifies the class indexes and access flags. More... | |
char | checkClassNameFileNameMatch (JavaClass *jc, const char *classFilePath) |
Checks whether the name of the class pointed by "thisClass" is the same name as the class file. More... | |
char | isValidJavaIdentifier (uint8_t *utf8_bytes, int32_t utf8_len, uint8_t isClassIdentifier) |
Checks whether the UTF-8 stream is a valid Java Identifier. More... | |
char | isValidUTF8Index (JavaClass *jc, uint16_t index) |
Identifies if a UTF8 index in JavaClass is valid. More... | |
char | isValidNameIndex (JavaClass *jc, uint16_t name_index, uint8_t isClassIdentifier) |
Identifies if a name index in JavaClass is valid. More... | |
char | isValidMethodNameIndex (JavaClass *jc, uint16_t name_index) |
checks if the name index points to a valid UTF-8 and is a valid java identifier. More... | |
char | checkClassIndex (JavaClass *jc, uint16_t class_index) |
Checks whether the index points to a valid class. More... | |
char | checkFieldNameAndTypeIndex (JavaClass *jc, uint16_t name_and_type_index) |
Checks if the name and the descriptor of a field are valid. More... | |
char | checkMethodNameAndTypeIndex (JavaClass *jc, uint16_t name_and_type_index) |
Checks if the name and the descriptor of a method are valid. More... | |
char | checkConstantPoolValidity (JavaClass *jc) |
Iterates over the constant pool looking for inconsistencies in it. More... | |
char checkClassIndex | ( | JavaClass * | jc, |
uint16_t | class_index | ||
) |
Checks whether the index points to a valid class.
JavaClass* | jc - pointer to the class holding the constant pool |
uint16_t | class_index - index to be check |
char checkClassIndexAndAccessFlags | ( | JavaClass * | jc | ) |
Verifies the class indexes and access flags.
Checks whether the accessFlags from the class file is a valid combination of class flags. This function also checks if "thisClass" and "superClass" points to valid class indexes.
JavaClass* | jc - pointer to the class to be checked |
char checkClassNameFileNameMatch | ( | JavaClass * | jc, |
const char * | classFilePath | ||
) |
Checks whether the name of the class pointed by "thisClass" is the same name as the class file.
This function also checks if the folder location match with the class package.
JavaClass* | jc - pointer to the class holding the constant pool |
char checkConstantPoolValidity | ( | JavaClass * | jc | ) |
Iterates over the constant pool looking for inconsistencies in it.
JavaClass* | jc - pointer to the javaClass holding the constant pool to be checked. |
char checkFieldAccessFlags | ( | JavaClass * | jc, |
uint16_t | accessFlags | ||
) |
Checks whether the "accessFlags" parameter has a valid combination of field flags.
The following status can be set by calling this function:
JavaClass* | jc - pointer to the class containing the field |
uint16_t | accessFlags - field flags to be checked |
char checkFieldNameAndTypeIndex | ( | JavaClass * | jc, |
uint16_t | name_and_type_index | ||
) |
Checks if the name and the descriptor of a field are valid.
JavaClass* | jc - pointer to the class holding the constant pool |
uint16_t | name_and_type_index - index of the name_and_type of a CONSTANT_Fieldref to be checked |
char checkMethodAccessFlags | ( | JavaClass * | jc, |
uint16_t | accessFlags | ||
) |
Checks whether the "accessFlags" parameter has a valid combination of method flags.
The following status can be set by calling this function:
JavaClass* | jc - pointer to the class containing the method |
uint16_t | accessFlags - method flags to be checked |
char checkMethodNameAndTypeIndex | ( | JavaClass * | jc, |
uint16_t | name_and_type_index | ||
) |
Checks if the name and the descriptor of a method are valid.
JavaClass* | jc - pointer to the class holding the constant pool |
uint16_t | name_and_type_index - index of the name_and_type of a CONSTANT_Methodref to be checked |
char isValidJavaIdentifier | ( | uint8_t * | utf8_bytes, |
int32_t | utf8_len, | ||
uint8_t | isClassIdentifier | ||
) |
Checks whether the UTF-8 stream is a valid Java Identifier.
A java identifer (class name, variable name, etc) must start with underscore, dollar sign or letter, and could finish with numbers, letters, dollar sign or underscore.
uint8_t* | utf8_bytes - pointer to the sequence of bytes that identify the class name |
int32_t | utf8_len - legth of class name |
uint8_t | isClassIdentifier - if set to anything but zero, then this function will accept slashes (/) as valid characters for identifiers. Classes have their full path separated by slashes, so this must be set to any value other than zero to check classes. |
char isValidMethodNameIndex | ( | JavaClass * | jc, |
uint16_t | name_index | ||
) |
checks if the name index points to a valid UTF-8 and is a valid java identifier.
The difference between this function and isValidNameIndex() is that this function accepts "<init>" and "<clinit>" as valid names for methods, whereas isValidNameIndex() (when consenquently calling isValidJavaIdentifier()) wouldn't accept those names as valid.
JavaClass* | jc - pointer to the class holding the constant pool |
uint16_t | name_index - name_index to be check |
char isValidNameIndex | ( | JavaClass * | jc, |
uint16_t | name_index, | ||
uint8_t | isClassIdentifier | ||
) |
Identifies if a name index in JavaClass is valid.
JavaClass* | jc - pointer to the class holding the constant pool |
uint8_t | isClassIdentifier - if set to zero, will not accept slashes (/) as valid identifier characters. If "isClassIdentifier" is different than zero, then classes with slashes in its name like "java/io/Stream" will be accepted as valid names. |
uint16_t | name_index - name_index to be checked. |
char isValidUTF8Index | ( | JavaClass * | jc, |
uint16_t | index | ||
) |
Identifies if a UTF8 index in JavaClass is valid.
JavaClass* | jc - pointer to the class holding the constant pool |
uint16_t | index - index of the UTF-8 constant in the constant pool |