SecureCoding-5.10

Converting a pointer to integer or integer to pointer

Required inputs: IR

Rule description is currently unavailable for legal reasons.

Possible Messages

Key

Text

Severity

Disabled

cast_changes_type_category

Conversion between pointer type and integer type

None

False

Options

allow_pointer_to_integer

allow_pointer_to_integer : bool = False

Allow casting pointer types to integer types of sufficient size.
 

allow_volatile_pointer_from_integer_literal

allow_volatile_pointer_from_integer_literal : bool = False

If this option is enabled, the rule will allow code such as: (volatile uint8_t*)0xABCD Such casts are often used for memory mapped I/O.
 

category_changes

category_changes

Type: list[typing.Tuple[typing.Set[bauhaus.ir.common.types.type_systems.TypeCategory], typing.Set[bauhaus.ir.common.types.type_systems.TypeCategory]]]

Default: [({'enum_types', 'signed_types', 'unsigned_types'}, {'object_pointer_types'}), ({'object_pointer_types'}, {'enum_types', 'signed_types', 'unsigned_types'}), ({'bool_types'}, {'object_pointer_types'}), ({'object_pointer_types'}, {'bool_types'}), ({'char_types'}, {'object_pointer_types'}), ({'object_pointer_types'}, {'char_types'})]

List of (from, to) type category pairs to check for. Both from and to are sets of categories.
 

check_explicit_casts

check_explicit_casts : bool = True

Whether explicit casts should be checked and reported.
 

check_implicit_casts

check_implicit_casts : bool = False

Whether implicit casts should be checked and reported.
 

look_through_casts

look_through_casts : bool = False

If true, operand after stripping casts is used.
 

only_complex_expressions

only_complex_expressions : bool = False

Whether all operands or only those deemed complex should be inspected.
 

show_operand_in_entity

show_operand_in_entity : bool = False

Whether entity should be "from->to" or "(from->to)operand".
 

type_system

type_system : bauhaus.ir.common.types.type_systems.TypeSystem = <bauhaus.ir.common.types.type_systems.CompilerTypeSystem object at 0x7f6f1c5fd510>

Which type system to use: compiler types, underlying types, essential types.
 

Option Types

These types are used by options listed above:

TypeCategory

Base class for the different type categories.
 

signed_types

unsigned_types

float_types

char_types

plain char.

bool_types

bool, _Bool and special expressions.

enum_types

void_types

void_pointer_types

incomplete_pointer_types

function_pointer_types

object_pointer_types

null_pointer_types

other_types

Those not covered by other categories.