Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:elfring:semantic_patching:Deletion_of_checks_before_specific_function_calls
Deletion_of_checks_before_specific_function_calls_in_Linux_source_files
find_input_parameter_validation1.cocci
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File find_input_parameter_validation1.cocci of Package Deletion_of_checks_before_specific_function_calls_in_Linux_source_files
// Copyright (c) 2015 Markus Elfring // // This file is part of a script collection for static source code analysis. // // The collection is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License (version 2) // as published by the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. @initialize:python@ URL << virtual.database_URL; @@ import sqlalchemy, sys sys.stderr.write("\n".join(["Using SQLAlchemy version:", sqlalchemy.__version__])) sys.stderr.write("\n") if URL == False or URL == "default": URL = "sqlite:///result-with_static.db" from sqlalchemy import create_engine, Column, Integer, String engine = create_engine(URL, echo = False) from sqlalchemy.ext.declarative import declarative_base base = declarative_base() class position(base): __tablename__ = "positions_parallel1" function = Column(String, primary_key = True) source_file = Column(String, primary_key = True) line = Column(Integer, primary_key = True) column = Column(Integer, primary_key = True) pattern = Column(Integer, primary_key = True) parameter = Column(String) data_type = Column(String) static = Column(Integer, default = 0) void = Column(Integer, default = 0) from sqlalchemy.orm import sessionmaker configured_session = sessionmaker(bind = engine) session = configured_session() base.metadata.create_all(engine) def store_positions(fun, type, point, places): """Add source code positions to an internal table.""" for place in places: entry = position(function = fun, source_file = place.file, line = place.line, column = int(place.column) + 1, pattern = 1, data_type = type, parameter = point ) session.add(entry) def store_positions2(fun, type, pointer, places): """Add source code positions to an internal table.""" for place in places: entry = position(function = fun, source_file = place.file, line = place.line, column = int(place.column) + 1, pattern = 2, data_type = " ".join([type, "*"]), parameter = pointer ) session.add(entry) def store_positions3(fun, type, pointer, places): """Add source code positions to an internal table.""" for place in places: entry = position(function = fun, source_file = place.file, line = place.line, column = int(place.column) + 1, pattern = 5, data_type = " ".join([type, "*"]), parameter = pointer ) session.add(entry) def store_static(fun, places): """Record that a function is static.""" for place in places: session.query(position) \ .filter_by(function = fun, source_file = place.file, line = place.line, column = int(place.column) + 1 ) \ .update({"static": 1}) def store_void(fun, places): '''Record that a function has got the return type "void".''' for place in places: session.query(position) \ .filter_by(function = fun, source_file = place.file, line = place.line, column = int(place.column) + 1 ) \ .update({"void": 1}) def store_void2(fun, type, point, places): """Add source code positions to an internal table.""" for place in places: entry = position(function = fun, source_file = place.file, line = place.line, column = int(place.column) + 1, pattern = 3, data_type = type, parameter = point, void = 1 ) session.add(entry) def store_void3(fun, type, pointer, places): """Add source code positions to an internal table.""" for place in places: entry = position(function = fun, source_file = place.file, line = place.line, column = int(place.column) + 1, pattern = 4, data_type = " ".join([type, "*"]), parameter = pointer, void = 1 ) session.add(entry) def store_void4(fun, type, pointer, places): """Add source code positions to an internal table.""" for place in places: entry = position(function = fun, source_file = place.file, line = place.line, column = int(place.column) + 1, pattern = 6, data_type = " ".join([type, "*"]), parameter = pointer, void = 1 ) session.add(entry) def store_void5(fun, type, pointer, places): """Add source code positions to an internal table.""" for place in places: entry = position(function = fun, source_file = place.file, line = place.line, column = int(place.column) + 1, pattern = 7, data_type = " ".join([type, "*"]), parameter = pointer, void = 1 ) session.add(entry) @safety_check@ expression assign, express; identifier input, work; position pos; statement is, es; type input_type, return_type; @@ return_type work@pos(input_type input) { ... when any when != (input = assign) ( if ( ( input | likely(input) | input > express | input >= express | input < express | input <= express ) ) is else es | switch (input) { case 0: return ... ; ... } ) ... when any } @script:python collection depends on safety_check@ fun << safety_check.work; typ << safety_check.input_type; point << safety_check.input; places << safety_check.pos; @@ store_positions(fun, typ, point, places) @safety_check_with_pointer@ expression assign; identifier input, local, local2, local3, member, member2, member3, process, work; position pos; statement is, es; type cast_type, data_type, data_type2, data_type3, input_type, return_type; @@ return_type work@pos(input_type * input) { ... when any when != (input = assign) when != data_type2 local2 = input->member2; when != data_type3 local3 = & input->member3; ( if ( ( !input | unlikely(ZERO_OR_NULL_PTR(input)) | !input || !process( ( input | input->member | & input->member ) ) | input && process( ( input | input->member | & input->member ) ) ) ) is else es | data_type local = (cast_type) input; if (unlikely(ZERO_OR_NULL_PTR(local))) is else es ) ... when any } @script:python collection_with_pointer depends on safety_check_with_pointer@ typ << safety_check_with_pointer.input_type; fun << safety_check_with_pointer.work; pointer << safety_check_with_pointer.input; places << safety_check_with_pointer.pos; @@ store_positions2(fun, typ, pointer, places) @safety_check_with_special_pointer disable unlikely@ expression assign; identifier input, local1, local2, member1, member2, work; position pos; statement is, es; type return_type, input_type, data_type1, data_type2; @@ return_type work@pos(input_type * input) { ... when any when != (input = assign) when != data_type1 local1 = input->member1; when != data_type2 local2 = & input->member2; if (unlikely(!input)) is else es ... when any } @script:python collection_with_special_pointer depends on safety_check_with_special_pointer@ typ << safety_check_with_special_pointer.input_type; fun << safety_check_with_special_pointer.work; pointer << safety_check_with_special_pointer.input; places << safety_check_with_special_pointer.pos; @@ store_positions3(fun, typ, pointer, places) @find_static depends on safety_check@ type safety_check.return_type; identifier safety_check.work; position safety_check.pos; @@ static return_type work@pos(...) { ... } @script:python static_addition depends on find_static@ fun << safety_check.work; places << safety_check.pos; @@ store_static(fun, places) @find_static_with_pointer depends on safety_check_with_pointer@ type safety_check_with_pointer.return_type; identifier safety_check_with_pointer.work; position safety_check_with_pointer.pos; @@ static return_type work@pos(...) { ... } @script:python static_addition_with_pointer depends on find_static_with_pointer@ fun << safety_check_with_pointer.work; places << safety_check_with_pointer.pos; @@ store_static(fun, places) @find_static_with_special_pointer depends on safety_check_with_special_pointer@ type safety_check_with_pointer.return_type; identifier safety_check_with_pointer.work; position safety_check_with_pointer.pos; @@ static return_type work@pos(...) { ... } @script:python static_addition_with_special_pointer depends on find_static_with_special_pointer@ fun << safety_check_with_special_pointer.work; places << safety_check_with_special_pointer.pos; @@ store_static(fun, places) @find_void depends on safety_check@ identifier safety_check.work; position safety_check.pos; @@ void work@pos(...) { ... } @script:python void_addition depends on find_void@ fun << safety_check.work; places << safety_check.pos; @@ store_void(fun, places) @find_void_with_pointer depends on safety_check_with_pointer@ identifier safety_check_with_pointer.work; position safety_check_with_pointer.pos; @@ void work@pos(...) { ... } @script:python void_addition_with_pointer depends on find_void_with_pointer@ fun << safety_check_with_pointer.work; places << safety_check_with_pointer.pos; @@ store_void(fun, places) @find_void_with_special_pointer depends on safety_check_with_special_pointer@ identifier safety_check_with_special_pointer.work; position safety_check_with_special_pointer.pos; @@ void work@pos(...) { ... } @script:python void_addition_with_special_pointer depends on find_void_with_special_pointer@ fun << safety_check_with_special_pointer.work; places << safety_check_with_special_pointer.pos; @@ store_void(fun, places) @void_single_function_call depends on safety_check@ identifier caller, input, member, safety_check.work; type input_type; position pos; @@ void caller@pos(..., input_type input, ...) { ( work( ( input | input.member ) ); | work( ( input | input.member ) ); return; ) } @script:python void_collection depends on void_single_function_call@ fun << void_single_function_call.caller; typ << void_single_function_call.input_type; point << void_single_function_call.input; places << void_single_function_call.pos; @@ store_void2(fun, typ, point, places) @find_static_builtin_safety_check depends on void_single_function_call@ identifier void_single_function_call.caller; position void_single_function_call.pos; @@ static void caller@pos(...) { ... } @script:python static_builtin_safety_check_addition depends on find_static_builtin_safety_check@ fun << void_single_function_call.caller; places << void_single_function_call.pos; @@ store_static(fun, places) @non_void_single_function_call depends on safety_check@ expression return_value; identifier caller, input, member, safety_check.work; position pos; type input_type, return_type; @@ return_type caller@pos(..., input_type input, ...) { work( ( input | input.member ) ); return return_value; } @script:python non_void_collection depends on non_void_single_function_call@ fun << non_void_single_function_call.caller; typ << non_void_single_function_call.input_type; point << non_void_single_function_call.input; places << non_void_single_function_call.pos; @@ store_void2(fun, typ, point, places) @find_static_non_void_builtin_safety_check depends on non_void_single_function_call@ identifier non_void_single_function_call.caller; position non_void_single_function_call.pos; type non_void_single_function_call.return_type; @@ static return_type caller@pos(...) { ... } @script:python static_non_void_builtin_safety_check_addition depends on find_static_non_void_builtin_safety_check@ fun << non_void_single_function_call.caller; places << non_void_single_function_call.pos; @@ store_static(fun, places) @void_single_function_call_with_pointer depends on safety_check_with_pointer@ identifier caller, input, safety_check_with_pointer.work; type input_type; position pos; @@ void caller@pos(..., input_type * input, ...) { ( work(input); | work(input); return; ) } @script:python void_collection_with_pointer depends on void_single_function_call_with_pointer@ fun << void_single_function_call_with_pointer.caller; typ << void_single_function_call_with_pointer.input_type; pointer << void_single_function_call_with_pointer.input; places << void_single_function_call_with_pointer.pos; @@ store_void3(fun, typ, pointer, places) @void_single_function_call_with_special_pointer depends on safety_check_with_special_pointer@ identifier caller, input, safety_check_with_special_pointer.work; type input_type; position pos; @@ void caller@pos(..., input_type * input, ...) { ( work(input); | work(input); return; ) } @script:python void_collection_with_special_pointer depends on void_single_function_call_with_special_pointer@ fun << void_single_function_call_with_special_pointer.caller; typ << void_single_function_call_with_special_pointer.input_type; pointer << void_single_function_call_with_special_pointer.input; places << void_single_function_call_with_special_pointer.pos; @@ store_void4(fun, typ, pointer, places) @find_static_builtin_safety_check_with_pointer depends on void_single_function_call_with_pointer@ identifier void_single_function_call_with_pointer.caller; position void_single_function_call_with_pointer.pos; @@ static void caller@pos(...) { ... } @script:python static_builtin_safety_check_addition_with_pointer depends on find_static_builtin_safety_check_with_pointer@ fun << void_single_function_call_with_pointer.caller; places << void_single_function_call_with_pointer.pos; @@ store_static(fun, places) @find_static_builtin_safety_check_with_special_pointer depends on void_single_function_call_with_special_pointer@ identifier void_single_function_call_with_special_pointer.caller; position void_single_function_call_with_special_pointer.pos; @@ static void caller@pos(...) { ... } @script:python static_builtin_safety_check_addition_with_special_pointer depends on find_static_builtin_safety_check_with_special_pointer@ fun << void_single_function_call_with_special_pointer.caller; places << void_single_function_call_with_special_pointer.pos; @@ store_static(fun, places) @non_void_single_function_call_with_pointer depends on safety_check_with_pointer@ expression return_value; identifier caller, input, safety_check_with_pointer.work; position pos; type input_type, return_type; @@ return_type caller@pos(..., input_type * input, ...) { work(input); return return_value; } @script:python non_void_collection_with_pointer depends on non_void_single_function_call_with_pointer@ fun << non_void_single_function_call_with_pointer.caller; typ << non_void_single_function_call_with_pointer.input_type; pointer << non_void_single_function_call_with_pointer.input; places << non_void_single_function_call_with_pointer.pos; @@ store_void3(fun, typ, pointer, places) @non_void_single_function_call_with_special_pointer depends on safety_check_with_special_pointer@ expression return_value; identifier caller, input, safety_check_with_pointer.work; position pos; type input_type, return_type; @@ return_type caller@pos(..., input_type * input, ...) { work(input); return return_value; } @script:python non_void_collection_with_special_pointer depends on non_void_single_function_call_with_special_pointer@ fun << non_void_single_function_call_with_special_pointer.caller; typ << non_void_single_function_call_with_special_pointer.input_type; pointer << non_void_single_function_call_with_special_pointer.input; places << non_void_single_function_call_with_special_pointer.pos; @@ store_void5(fun, typ, pointer, places) @find_static_non_void_builtin_safety_check_with_pointer depends on non_void_single_function_call_with_pointer@ identifier non_void_single_function_call_with_pointer.caller; position non_void_single_function_call_with_pointer.pos; type non_void_single_function_call_with_pointer.return_type; @@ static return_type caller@pos(...) { ... } @script:python static_non_void_builtin_safety_check_addition_with_pointer depends on find_static_non_void_builtin_safety_check_with_pointer@ fun << non_void_single_function_call_with_pointer.caller; places << non_void_single_function_call_with_pointer.pos; @@ store_static(fun, places) @finalize:python@ @@ session.commit() from sqlalchemy import func entries = session.query(func.count("*")).select_from(position).scalar() if entries < 1: sys.stderr.write("No result for this analysis!\n")
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor