CN110674495A - Detection method, device and equipment for group border crossing access - Google Patents
Detection method, device and equipment for group border crossing access Download PDFInfo
- Publication number
- CN110674495A CN110674495A CN201910828384.9A CN201910828384A CN110674495A CN 110674495 A CN110674495 A CN 110674495A CN 201910828384 A CN201910828384 A CN 201910828384A CN 110674495 A CN110674495 A CN 110674495A
- Authority
- CN
- China
- Prior art keywords
- statement
- array
- functions
- function
- program
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/50—Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
- G06F21/52—Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/50—Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
- G06F21/55—Detecting local intrusion or implementing counter-measures
- G06F21/56—Computer malware detection or handling, e.g. anti-virus arrangements
- G06F21/562—Static detection
- G06F21/563—Static detection by source code analysis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/42—Syntactic analysis
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Computer Hardware Design (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Health & Medical Sciences (AREA)
- General Health & Medical Sciences (AREA)
- Virology (AREA)
- Stored Programmes (AREA)
Abstract
Description
技术领域technical field
本文件涉及计算机技术领域,尤其涉及一种数组越界访问的检测方法、装置及设备。This document relates to the field of computer technology, and in particular, to a detection method, device and device for out-of-bounds access to an array.
背景技术Background technique
数组越界访问是一种常见的程序编码缺陷,数组越界访问会导致程序运行过程中崩溃或程序运行结果不正确等,而且,它还会导致严重的系统安全问题,攻击者可以利用该缺陷提升攻击者自身的权限,从而读取或修改用户的敏感数据。Array out-of-bounds access is a common program coding defect. Array out-of-bounds access can cause program crashes or incorrect program results. Moreover, it can also lead to serious system security problems. Attackers can use this defect to enhance their attacks. The user's own permissions to read or modify the user's sensitive data.
目前,找出程序中数组越界访问的方法通常可以是基于黑盒测试或白盒测试的方法,即通过构造测试用例来测试执行程序,并观察程序执行中是否存在数组越界访问。在上述数组越界访问检测的方法中,对于黑盒测试或白盒测试的方法,无法构造足够的测试用例来覆盖该程序代码的所有执行路径,因此,该方法的检测准确性低、而且检测效率低。为此,需要提供一种能够检测跨函数或跨文件的数组越界访问机制,并且该机制的检测速度可以更快、检测准确度更高,能够在更大的范围内检测程序代码中的数组越界访问缺陷。At present, the method of finding out-of-bounds access to arrays in a program can usually be based on black-box testing or white-box testing, that is, construct test cases to test the execution program and observe whether there is an out-of-bounds access to arrays in program execution. In the above-mentioned method of array out-of-bounds access detection, for the method of black-box testing or white-box testing, it is impossible to construct enough test cases to cover all execution paths of the program code. Therefore, the detection accuracy of this method is low and the detection efficiency is high. Low. To this end, it is necessary to provide a mechanism that can detect cross-function or cross-file array out-of-bounds access, and the detection speed of the mechanism can be faster, the detection accuracy is higher, and the array out-of-bounds access in program code can be detected in a larger range. access defect.
发明内容SUMMARY OF THE INVENTION
本说明书实施例的目的是提供一种数组越界访问的检测方法、装置及设备,以提供一种能够检测跨函数或跨文件的数组越界访问机制,并且该机制的检测速度可以更快、检测准确度更高,能够在更大的范围内检测程序代码中的数组越界访问缺陷。The purpose of the embodiments of this specification is to provide a detection method, device and device for out-of-bounds access to an array, so as to provide a mechanism that can detect out-of-bounds access to an array across functions or files, and the detection speed of the mechanism can be faster and accurate. It has a higher degree and can detect array out-of-bounds access defects in program code in a wider range.
为了实现上述技术方案,本说明书实施例是这样实现的:In order to realize the above technical solutions, the embodiments of this specification are implemented as follows:
本说明书实施例提供的一种数组越界访问的检测方法,所述方法包括:A method for detecting array out-of-bounds access provided by the embodiments of this specification includes:
获取待检测的程序代码中包含的函数,以及所述函数之间的调用关系信息;Obtain the functions contained in the program code to be detected, and the calling relationship information between the functions;
如果所述函数之间的调用关系信息中包括未被访问的目标程序语句,则检测所述目标程序语句是否需要访问数组;If the calling relationship information between the functions includes an unvisited target program statement, then detect whether the target program statement needs to access an array;
如果所述目标程序语句需要访问数组,则获取所述目标程序语句访问的数组的预定变量在所述数组对应的程序区域内的值范围;If the target program statement needs to access the array, then obtain the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array;
基于所述目标程序语句访问的数组的预定变量在所述数组对应的程序区域内的值范围,对所述程序代码中是否包含数组越界访问进行检测。Based on the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array, it is detected whether the program code includes out-of-bounds access to the array.
可选地,所述获取待检测的程序代码中包含的函数,以及所述函数之间的调用关系信息之后,所述方法还包括:Optionally, after acquiring the functions contained in the program code to be detected and the calling relationship information between the functions, the method further includes:
检测所述函数之间的调用关系信息中是否包括未被访问的函数;Detecting whether the calling relationship information between the functions includes unvisited functions;
如果所述函数之间的调用关系信息中包括未被访问的函数,则将所述未被访问的函数中的程序语句作为所述目标程序语句;If the calling relationship information between the functions includes an unvisited function, use the program statement in the unvisited function as the target program statement;
如果所述函数之间的调用关系信息中不包括未被访问的函数,则检测所述函数之间的调用关系信息中是否包括未被访问的目标程序语句。If the invocation relationship information between the functions does not include unvisited functions, it is detected whether the invocation relation information between the functions includes an unvisited target program statement.
可选地,所述方法还包括:Optionally, the method further includes:
将所述待检测的程序代码转换为预定表达形式的程序代码;Converting the program code to be detected into program code in a predetermined expression form;
所述获取待检测的程序代码中包含的函数,以及所述函数之间的调用关系信息,包括:The acquisition of the functions contained in the program code to be detected, and the calling relationship information between the functions, include:
获取转换为预定表达形式的程序代码中包含的函数,以及所述函数之间的调用关系信息。The functions contained in the program code converted into a predetermined expression form and the calling relationship information between the functions are acquired.
可选地,所述方法还包括:Optionally, the method further includes:
对转换后的程序代码中包含的函数的程序语句的结构进行识别,得到识别结果;Identify the structure of the program statement of the function contained in the converted program code, and obtain the identification result;
如果所述识别结果指示所述函数的程序语句为循环语句,则获取所述函数的程序语句对应的循环归纳变量和循环体;If the identification result indicates that the program statement of the function is a loop statement, acquiring the loop induction variable and the loop body corresponding to the program statement of the function;
确定所述循环归纳变量在所述循环体内的值范围。A range of values for the loop induction variable within the loop body is determined.
可选地,所述方法还包括:Optionally, the method further includes:
如果所述识别结果指示所述函数的程序语句为IF分支语句,则获取所述函数的程序语句对应的THEN语句块、ELSE语句块和条件判断变量;If the identification result indicates that the program statement of the function is an IF branch statement, then obtain the THEN statement block, the ELSE statement block and the condition judgment variable corresponding to the program statement of the function;
分别确定所述条件判断变量在所述THEN语句块内的值范围和在所述ELSE语句块内的值范围。The value range of the condition judgment variable in the THEN statement block and the value range in the ELSE statement block are respectively determined.
可选地,所述方法还包括:Optionally, the method further includes:
如果所述识别结果指示所述函数的程序语句为SWITCH选择语句,则获取所述函数的程序语句对应的CASE语句值及其对应的CASE语句块、DEFAULT语句块和选择变量;If the identification result indicates that the program statement of the function is a SWITCH selection statement, then obtain the CASE statement value corresponding to the program statement of the function and its corresponding CASE statement block, DEFAULT statement block and selection variable;
确定所述选择变量在每个CASE语句块内的值范围和在所述DEFAULT语句块内的值范围。Determine the value range of the selection variable within each CASE statement block and the value range within the DEFAULT statement block.
可选地,所述获取所述函数之间的调用关系信息,包括:Optionally, the acquiring the calling relationship information between the functions includes:
对所述函数之间的调用关系进行分析,得到函数调用图谱,所述函数调用图谱中包括多个函数和所述多个函数之间的连接线;Analyzing the calling relationship between the functions to obtain a function calling graph, where the function calling graph includes multiple functions and connecting lines between the multiple functions;
将所述函数调用图谱中的函数的形式参数与所述函数在所述函数调用图谱中的实际参数相连接,得到参数连接信息;Connect the formal parameters of the function in the function call map with the actual parameters of the function in the function call map to obtain parameter connection information;
获取预定的全局变量在所述函数调用图谱中各个函数之间的使用和定义关系,得到全局变量使用定义连接信息。The usage and definition relationship between each function in the function call graph of the predetermined global variable is acquired, and the connection information of the usage definition of the global variable is obtained.
可选地,所述如果所述目标程序语句需要访问数组,则获取所述目标程序语句访问的数组的预定变量在所述数组对应的程序区域内的值范围,包括:Optionally, if the target program statement needs to access an array, obtain the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array, including:
如果所述目标程序语句需要访问数组,则根据预定的使用定义关系信息,确定所述目标程序语句访问的数组的定义;If the target program statement needs to access the array, then according to the predetermined use definition relationship information, determine the definition of the array accessed by the target program statement;
根据预定的使用定义关系信息和所述目标程序语句访问的数组的定义对应的记录信息,查询所述目标程序语句访问的数组中每一维预定变量在所述数组对应的程序区域内的值范围。According to the predetermined usage definition relationship information and the record information corresponding to the definition of the array accessed by the target program statement, query the value range of each dimension of the predetermined variable in the array accessed by the target program statement in the program area corresponding to the array .
本说明书实施例提供的一种数组越界访问的检测装置,所述装置包括:An apparatus for detecting array out-of-bounds access provided by the embodiments of this specification includes:
信息获取模块,用于获取待检测的程序代码中包含的函数,以及所述函数之间的调用关系信息;an information acquisition module, used for acquiring the functions contained in the program code to be detected, and the calling relationship information between the functions;
数组访问检测模块,用于如果所述函数之间的调用关系信息中包括未被访问的目标程序语句,则检测所述目标程序语句是否需要访问数组;an array access detection module for detecting whether the target program statement needs to access an array if the calling relationship information between the functions includes an unvisited target program statement;
值范围获取模块,用于如果所述目标程序语句需要访问数组,则获取所述目标程序语句访问的数组的预定变量在所述数组对应的程序区域内的值范围;A value range acquisition module, configured to obtain the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array if the target program statement needs to access the array;
越界访问检测模块,用于基于所述目标程序语句访问的数组的预定变量在所述数组对应的程序区域内的值范围,对所述程序代码中是否包含数组越界访问进行检测。The out-of-bounds access detection module is configured to detect whether the program code includes out-of-bounds access to the array based on the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array.
可选地,所述装置还包括:Optionally, the device further includes:
函数检测模块,用于检测所述函数之间的调用关系信息中是否包括未被访问的函数;a function detection module, configured to detect whether the calling relationship information between the functions includes unvisited functions;
函数检测结果模块,用于如果所述函数之间的调用关系信息中包括未被访问的函数,则将所述未被访问的函数中的程序语句作为所述目标程序语句;A function detection result module, configured to use the program statement in the unvisited function as the target program statement if the calling relationship information between the functions includes an unvisited function;
语句检测模块,用于如果所述函数之间的调用关系信息中不包括未被访问的函数,则检测所述函数之间的调用关系信息中是否包括未被访问的目标程序语句。A statement detection module, configured to detect whether the calling relationship information between the functions includes an unvisited target program statement if the calling relationship information between the functions does not include an unvisited function.
可选地,所述装置还包括:Optionally, the device further includes:
转换模块,用于将所述待检测的程序代码转换为预定表达形式的程序代码;a conversion module for converting the program code to be detected into a program code of a predetermined expression form;
所述信息获取模块,用于获取转换为预定表达形式的程序代码中包含的函数,以及所述函数之间的调用关系信息。The information acquisition module is used for acquiring the functions contained in the program code converted into a predetermined expression form, and the calling relationship information between the functions.
可选地,所述装置还包括:Optionally, the device further includes:
识别模块,用于对转换后的程序代码中包含的函数的程序语句的结构进行识别,得到识别结果;The identification module is used to identify the structure of the program statement of the function contained in the converted program code, and obtain the identification result;
第一语句处理模块,用于如果所述识别结果指示所述函数的程序语句为循环语句,则获取所述函数的程序语句对应的循环归纳变量和循环体;a first statement processing module, configured to acquire a loop induction variable and a loop body corresponding to the program statement of the function if the identification result indicates that the program statement of the function is a loop statement;
第一值范围确定模块,用于确定所述循环归纳变量在所述循环体内的值范围。The first value range determination module is used for determining the value range of the loop induction variable in the loop body.
可选地,所述装置还包括:Optionally, the device further includes:
第二语句处理模块,用于如果所述识别结果指示所述函数的程序语句为IF分支语句,则获取所述函数的程序语句对应的THEN语句块、ELSE语句块和条件判断变量;The second statement processing module is used to obtain the THEN statement block, the ELSE statement block and the condition judgment variable corresponding to the program statement of the function if the recognition result indicates that the program statement of the function is an IF branch statement;
第二值范围确定模块,用于分别确定所述条件判断变量在所述THEN语句块内的值范围和在所述ELSE语句块内的值范围。The second value range determination module is configured to respectively determine the value range of the condition judgment variable in the THEN statement block and the value range in the ELSE statement block.
可选地,所述装置还包括:Optionally, the device further includes:
第三语句处理模块,用于如果所述识别结果指示所述函数的程序语句为SWITCH选择语句,则获取所述函数的程序语句对应的CASE语句值及其对应的CASE语句块、DEFAULT语句块和选择变量;A third statement processing module, configured to acquire the CASE statement value corresponding to the program statement of the function and its corresponding CASE statement block, DEFAULT statement block and select variable;
第三值范围确定模块,用于确定所述选择变量在每个CASE语句块内的值范围和在所述DEFAULT语句块内的值范围。The third value range determination module is used for determining the value range of the selection variable in each CASE statement block and the value range in the DEFAULT statement block.
可选地,所述信息获取模块,包括:Optionally, the information acquisition module includes:
调用图确定单元,用于对所述函数之间的调用关系进行分析,得到函数调用图谱,所述函数调用图谱中包括多个函数和所述多个函数之间的连接线;a call graph determination unit, configured to analyze the calling relationship between the functions to obtain a function call graph, where the function call graph includes multiple functions and connecting lines between the multiple functions;
参数连接确定单元,用于将所述函数调用图谱中的函数的形式参数与所述函数在所述函数调用图谱中的实际参数相连接,得到参数连接信息;a parameter connection determination unit, configured to connect the formal parameters of the function in the function call map with the actual parameters of the function in the function call map to obtain parameter connection information;
连接信息确定单元,用于获取预定的全局变量在所述函数调用图谱中各个函数之间的使用和定义关系,得到全局变量使用定义连接信息。The connection information determination unit is configured to acquire the usage and definition relationship between the functions of the predetermined global variables in the function call graph, and obtain the usage definition connection information of the global variables.
可选地,所述值范围获取模块,包括:Optionally, the value range acquisition module includes:
定义确定单元,用于如果所述目标程序语句需要访问数组,则根据预定的使用定义关系信息,确定所述目标程序语句访问的数组的定义;A definition determining unit is used to determine the definition of the array accessed by the target program statement according to predetermined use definition relationship information if the target program statement needs to access the array;
值范围获取单元,用于根据预定的使用定义关系信息和所述目标程序语句访问的数组的定义对应的记录信息,查询所述目标程序语句访问的数组中每一维预定变量在所述数组对应的程序区域内的值范围。The value range acquisition unit is used to query the corresponding record information of each dimension of the array accessed by the target program statement according to the predetermined use definition relationship information and the corresponding record information of the definition of the array accessed by the target program statement. range of values within the program area of .
本说明书实施例提供的一种数组越界访问的检测设备,所述数组越界访问的检测设备包括:A detection device for out-of-bounds access to an array provided by the embodiments of this specification, the detection device for out-of-bounds access to an array includes:
处理器;以及processor; and
被安排成存储计算机可执行指令的存储器,所述可执行指令在被执行时使所述处理器:memory arranged to store computer-executable instructions which, when executed, cause the processor to:
获取待检测的程序代码中包含的函数,以及所述函数之间的调用关系信息;Obtain the functions contained in the program code to be detected, and the calling relationship information between the functions;
如果所述函数之间的调用关系信息中包括未被访问的目标程序语句,则检测所述目标程序语句是否需要访问数组;If the calling relationship information between the functions includes an unvisited target program statement, then detect whether the target program statement needs to access an array;
如果所述目标程序语句需要访问数组,则获取所述目标程序语句访问的数组的预定变量在所述数组对应的程序区域内的值范围;If the target program statement needs to access the array, then obtain the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array;
基于所述目标程序语句访问的数组的预定变量在所述数组对应的程序区域内的值范围,对所述程序代码中是否包含数组越界访问进行检测。Based on the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array, it is detected whether the program code includes out-of-bounds access to the array.
由以上本说明书实施例提供的技术方案可见,本说明书实施例通过获取待检测的程序代码中包含的函数,以及该函数之间的调用关系信息,如果该函数之间的调用关系信息中包括未被访问的目标程序语句,则检测目标程序语句是否需要访问数组,如果目标程序语句需要访问数组,则获取目标程序语句访问的数组的预定变量在该数组对应的程序区域内的值范围,基于目标程序语句访问的数组的预定变量在所述数组对应的程序区域内的值范围,对程序代码中是否包含数组越界访问进行检测,这样,通过对函数之间的调用关系信息中的程序语句的检测,来确定程序代码中是否包含数组越界访问,因此,可以使得该检测过程可以覆盖该程序代码的所有执行路径,提高了检测的准确性,此外,通过对函数之间的调用关系信息中的程序语句的检测和获取数组的预定变量在该数组对应的程序区域内的值范围,来进一步对程序代码中是否包含数组越界访问进行检测,可以使得数组越界访问的检测效率更高。It can be seen from the technical solutions provided by the above embodiments of this specification that the embodiments of this specification obtain the functions contained in the program code to be detected and the calling relationship information between the functions. The accessed target program statement checks whether the target program statement needs to access the array. If the target program statement needs to access the array, obtain the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array, based on the target The value range of the predetermined variable of the array accessed by the program statement in the program area corresponding to the array is to detect whether the program code contains array out-of-bounds access. In this way, by detecting the program statement in the calling relationship information between functions , to determine whether the program code contains array out-of-bounds access. Therefore, the detection process can cover all execution paths of the program code, and the detection accuracy is improved. The detection of the statement and the acquisition of the value range of the predetermined variable of the array in the program area corresponding to the array to further detect whether the program code includes out-of-bounds access to the array can make the detection of out-of-bounds access to the array more efficient.
附图说明Description of drawings
为了更清楚地说明本说明书实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本说明书中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present specification or the prior art, the following briefly introduces the accompanying drawings required in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments described in this specification. For those of ordinary skill in the art, other drawings can also be obtained according to these drawings without creative labor.
图1为本说明书一种数组越界访问的检测方法实施例;Fig. 1 is a kind of detection method embodiment of array out-of-bounds access of this specification;
图2为本说明书另一种数组越界访问的检测方法实施例;Fig. 2 is the detection method embodiment of another kind of array out-of-bounds access of this specification;
图3为本说明书一种循环语句的结构示意图;Fig. 3 is the structural representation of a kind of loop statement of this specification;
图4为本说明书另一种循环语句的结构示意图;Fig. 4 is the structural representation of another kind of loop statement of this specification;
图5为本说明书又一种循环语句的结构示意图;Fig. 5 is the structural representation of another kind of loop statement of this specification;
图6为本说明书一种IF分支语句的结构示意图;Fig. 6 is the structural representation of a kind of IF branch statement of this specification;
图7为本说明书另一种IF分支语句的结构示意图;Fig. 7 is the structural representation of another kind of IF branch statement of this specification;
图8为本说明书一种SWITCH选择语句的结构示意图;Fig. 8 is the structural representation of a kind of SWITCH selection statement of this specification;
图9为本说明书一种调用关系图谱的结构示例图;Fig. 9 is a structural example diagram of a calling relationship graph of this specification;
图10为本说明书一种数组越界访问的检测装置实施例;10 is an embodiment of a detection device for out-of-bounds access to an array of this specification;
图11为本说明书一种数组越界访问的检测设备实施例。FIG. 11 is an embodiment of a detection device for out-of-bounds access to an array in this specification.
具体实施方式Detailed ways
本说明书实施例提供一种数组越界访问的检测方法、装置及设备。Embodiments of the present specification provide a method, apparatus, and device for detecting out-of-bounds access to an array.
为了使本技术领域的人员更好地理解本说明书中的技术方案,下面将结合本说明书实施例中的附图,对本说明书实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本说明书一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都应当属于本文件保护的范围。In order to make those skilled in the art better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings in the embodiments of this specification. Obviously, the described The embodiments are only some of the embodiments of the present specification, but not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by persons of ordinary skill in the art without creative efforts shall fall within the protection scope of this document.
实施例一Example 1
如图1所示,本说明书实施例提供一种数组越界访问的检测方法,该方法的执行主体可以为终端设备或服务器,其中,该终端设备可以如手机、平板电脑等,该服务器可以是一个独立的服务器,还可以是由多个服务器构成的服务器集群等。该服务器可以是某项业务(如进行交易的业务等)的后台服务器,也可以是某应用(如金融类应用等)的后台服务器等。该方法具体可以包括以下步骤:As shown in FIG. 1 , an embodiment of this specification provides a detection method for out-of-bounds access to an array. The execution body of the method may be a terminal device or a server, wherein the terminal device may be a mobile phone, a tablet computer, etc., and the server may be a An independent server may also be a server cluster composed of multiple servers, or the like. The server may be a background server of a certain business (such as a transaction business, etc.), or a background server of a certain application (such as a financial application, etc.). The method may specifically include the following steps:
在步骤S102中,获取待检测的程序代码中包含的函数,以及上述函数之间的调用关系信息。In step S102, the functions included in the program code to be detected and the calling relationship information between the above functions are acquired.
其中,待检测的程序代码可以是任意需要检测其中是否存在数组越界访问的程序代码。上述函数之间的调用关系信息可以是不同函数之间相互调用中的相关信息等。The program code to be detected may be any program code that needs to detect whether there is an out-of-bounds access to the array. The calling relationship information between the above functions may be related information in mutual calls between different functions, and the like.
在实施中,数组越界访问是一种常见的程序编码缺陷,数组越界访问会导致程序运行过程中崩溃或程序运行结果不正确等,而且,它还会导致严重的系统安全问题,攻击者可以利用该缺陷提升攻击者自身的权限,从而读取或修改用户的敏感数据。In implementation, out-of-bounds access to an array is a common program coding defect. An out-of-bounds access to an array can cause a program crash or incorrect program execution results. Moreover, it can also lead to serious system security problems. Attackers can exploit The flaw escalates the attacker's own privileges to read or modify a user's sensitive data.
目前,找出程序中数组越界访问的方法通常可以包括四种:一是基于黑盒测试或白盒测试的方法,即通过构造测试用例来测试执行程序,并观察程序执行中是否存在数组越界访问。二是符号执行的方法,即枚举该程序代码的所有可能的输入组合,然后,通过符号执行机制模拟执行该程序代码,在模拟执行该程序代码的过程中检测该程序代码中是否存在数组越界访问。三是代码插桩运行时的检测方法,即利用代码插桩机制在程序代码中插入额外的检测代码,在程序代码执行过程中检测其中是否存在数组越界访问。四是程序静态检测方法,利用程序静态分析机制分析程序中访问数组时下标是否在数组许可范围内。At present, there are usually four methods to find out the out-of-bounds access of arrays in the program: one is the method based on black-box testing or white-box testing, that is, to test the execution program by constructing test cases, and observe whether there is out-of-bounds access to the array in the program execution. . The second is the method of symbolic execution, that is, enumerating all possible input combinations of the program code, then simulating the execution of the program code through the symbolic execution mechanism, and detecting whether there is an array out of bounds in the program code during the process of simulating the execution of the program code access. The third is the detection method when the code instrumentation is running, that is, using the code instrumentation mechanism to insert additional detection code into the program code, and detect whether there is an array out-of-bounds access in the program code execution process. The fourth is the program static detection method, which uses the program static analysis mechanism to analyze whether the subscript is within the permitted range of the array when accessing the array in the program.
在上述数组越界访问检测的方法中,黑盒测试或白盒测试的方法的缺点在于无法构造足够的测试用例来覆盖该程序代码的所有执行路径,对于符号执行的方法,该方法检测效率低,检测时间过长,检测时占用的内存大,对于代码插桩运行时的检测方法,该方法显著降低了程序代码的执行速度,对于程序静态检测方法,通常将该方法的检测范围局限在函数内部,难以发现跨函数或跨文件的数据越界访问的缺陷。为此,本说明书实施例需要提供一种能够检测跨函数或跨文件的数组越界访问机制,并且该机制的加测速度可以更快、占用内存更少,能够在更大的范围内检测程序代码中的数组越界访问缺陷。本说明书实施例提供一种相关技术方案,具体可以包括以下内容:Among the above methods for detecting out-of-bounds access to arrays, the disadvantage of black-box testing or white-box testing is that enough test cases cannot be constructed to cover all execution paths of the program code. For the method of symbolic execution, the detection efficiency of this method is low. The detection time is too long, and the memory occupied by the detection is large. For the detection method when the code is instrumented and running, this method significantly reduces the execution speed of the program code. For the program static detection method, the detection range of this method is usually limited to the inside of the function. , it is difficult to find the defect of cross-function or cross-file data cross-boundary access. To this end, the embodiments of this specification need to provide a mechanism that can detect cross-function or cross-file array out-of-bounds access, and the mechanism can have faster acceleration, less memory, and can detect program codes in a wider range. Array out-of-bounds access defect in . The embodiments of this specification provide a related technical solution, which may specifically include the following content:
当需要对某一段或多段程序代码进行数组越界访问的检测时,可以获取待检测的程序代码,在实际应用中,可以通过多种方式获取待检测的程序代码,例如,可以通过用户上传的方式实现,即可以预先设定程序代码的上传页面,该上传页面中可以包括代码上传输入框、上传按键和取消按键等,用户可以将待检测的程序代码输入到上述代码上传输入框中,输入完成后,可以点击上传按键,此时,上传页面所在的终端设备可以获取用户在代码输入框中输入的程序代码,并可以将该程序代码发送给服务器,从而服务器可以获取到待检测的程序代码。服务器可以对待检测的程序代码中包含的内容进行分析,确定其中包含的函数,并可以获取不同的函数之间的调用关系信息。When it is necessary to perform array out-of-bounds access detection on a certain or multiple pieces of program code, the program code to be detected can be obtained. In practical applications, the program code to be detected can be obtained in various ways, for example, it can be uploaded by the user. Realization, that is, the upload page of the program code can be preset, and the upload page can include a code upload input box, an upload button and a cancel button, etc., the user can input the program code to be detected into the above code upload input box, and the input is completed. Then, the upload button can be clicked. At this time, the terminal device where the upload page is located can obtain the program code input by the user in the code input box, and can send the program code to the server, so that the server can obtain the program code to be detected. The server can analyze the content contained in the program code to be detected, determine the functions contained therein, and obtain the calling relationship information between different functions.
在实际应用中,数组越界访问往往会发生在函数中,因此,为了使得程序代码中的函数更加直观的体现,可以在基于不同函数之间的调用关系信息生成不同函数之间的函数调用图谱,可以基于该函数调用图谱进行后续的相应处理。In practical applications, array out-of-bounds access often occurs in functions. Therefore, in order to make the functions in the program code more intuitive, the function call graph between different functions can be generated based on the calling relationship information between different functions. Subsequent corresponding processing can be performed based on the function call graph.
在步骤S104中,如果上述函数之间的调用关系信息中包括未被访问的目标程序语句,则检测目标程序语句是否需要访问数组。In step S104, if the calling relationship information between the above functions includes the target program statement that has not been accessed, it is detected whether the target program statement needs to access the array.
其中,目标程序语句可以是任意的程序语句。The target program statement may be any program statement.
在实施中,可以通过检测函数调用图谱中是否还包括未被访问的程序语句来进行数组越界访问的检测,具体地,可以对上述得到的函数调用关系信息进行分析,并可以在服务器中查找其中是否包含函数调用关系信息中各个程序语句被访问的记录信息,如果未查找到某程序语句被访问的记录信息,则表明该程序语句未被访问,此时,可以检测目标程序语句是否需要访问预定的数组,具体可以通过目标程序语句中是否包含预先设定的关键字或关键词等,如果其中包含上述的关键字或关键词,则表明目标程序语句需要访问数组,此时,可以执行下述步骤S106的处理,如果其中不包含上述的关键字或关键词,则表明目标程序语句不需要访问数组。如果查找到所有程序语句被访问的记录信息,则表明上述函数之间的调用关系信息中的程序语句均被访问。In implementation, the detection of array out-of-bounds access can be performed by detecting whether the function call graph also includes unvisited program statements. Specifically, the function call relationship information obtained above can be analyzed, and the server can be searched for among them. Whether it contains the access record information of each program statement in the function call relationship information. If the record information of a program statement being accessed is not found, it means that the program statement has not been accessed. At this time, it can be detected whether the target program statement needs to be accessed. Specifically, whether the target program statement contains preset keywords or keywords, etc., if it contains the above keywords or keywords, it indicates that the target program statement needs to access the array. At this time, you can execute the following In the process of step S106, if the above keywords or keywords are not included, it indicates that the target program statement does not need to access the array. If the record information that all program statements are accessed is found, it indicates that all program statements in the calling relationship information between the above functions are accessed.
需要说明的是,上述检测目标程序语句是否需要访问预定的数组的方式仅是一种可选的处理方式,在实际应用中还可以包含多种不同的处理方式,具体可以根据实际情况设定,本说明书实施例对此不做限定。It should be noted that the above-mentioned method of detecting whether the target program statement needs to access a predetermined array is only an optional processing method. In practical applications, it can also include a variety of different processing methods, which can be set according to the actual situation. The embodiments of the present specification do not limit this.
在步骤S106中,如果目标程序语句需要访问数组,则获取目标程序语句访问的数组的预定变量在该数组对应的程序区域内的值范围。In step S106, if the target program statement needs to access the array, the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array is obtained.
其中,预定变量可以是数组的下标中存在的变量,预定变量可以包括一个或多个,其中数组可以包括一维或多维数组,每一维数组可以设置变量,该变量可以位于下标中(也可以称为下标变量)等。The predetermined variable may be a variable existing in the subscript of the array, and the predetermined variable may include one or more, wherein the array may include one-dimensional or multi-dimensional arrays, and each dimension of the array may be set to a variable, and the variable may be located in the subscript ( It can also be called a subscript variable) and so on.
在实施中,可以预先设置变量值范围分析机制,可以对上述函数之间的调用关系信息中包含的程序语句进行分析确定变量在分支不同的区域内的取值范围。如果通过上述处理方式确定目标程序语句需要访问数组,则可以通过预先设定的溯源机制,查找到该数组的定义,然后,可以获取目标程序语句访问的数组的预定变量,可以通过变量值范围分析机制,确定该数组的预定变量在该数组对应的程序区域内的取值范围。In implementation, a variable value range analysis mechanism may be preset, and the program statement included in the calling relationship information between the functions may be analyzed to determine the value range of the variable in different branches. If it is determined through the above processing methods that the target program statement needs to access the array, the definition of the array can be found through the preset traceability mechanism, and then the predetermined variable of the array accessed by the target program statement can be obtained, which can be analyzed through the variable value range analysis. The mechanism determines the value range of the predetermined variables of the array in the program area corresponding to the array.
在步骤S108中,基于目标程序语句访问的数组的预定变量在该数组对应的程序区域内的值范围,对程序代码中是否包含数组越界访问进行检测。In step S108 , based on the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array, it is detected whether the program code includes out-of-bounds access to the array.
在实施中,可以将目标程序语句访问的数组的预定变量在该数组对应的程序区域内的值范围与目标程序语句需要访问的数组对应的维度个数进行对比,如果目标程序语句访问的数组的预定变量在该数组对应的程序区域内的值范围与目标程序语句需要访问的数组对应的维度个数相同,则表明目标程序语句中不存在数组越界访问。如果目标程序语句访问的数组的预定变量在该数组对应的程序区域内的值范围大于目标程序语句需要访问的数组对应的维度个数,则表明目标程序语句中存在数组越界访问,此时,可以对目标程序语句进行相应的处理,具体可以根据实际情况设定,本说明书实施例对此不做限定。In implementation, the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array can be compared with the number of dimensions corresponding to the array to be accessed by the target program statement. The value range of the predetermined variable in the program area corresponding to the array is the same as the number of dimensions corresponding to the array to be accessed by the target program statement, indicating that there is no out-of-bounds access to the array in the target program statement. If the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array is greater than the number of dimensions corresponding to the array to be accessed by the target program statement, it indicates that there is an array out-of-bounds access in the target program statement. Corresponding processing is performed on the target program statement, which may be specifically set according to the actual situation, which is not limited in the embodiment of this specification.
本说明书实施例提供一种数组越界访问的检测方法,通过获取待检测的程序代码中包含的函数,以及该函数之间的调用关系信息,如果该函数之间的调用关系信息中包括未被访问的目标程序语句,则检测目标程序语句是否需要访问数组,如果目标程序语句需要访问数组,则获取目标程序语句访问的数组的预定变量在该数组对应的程序区域内的值范围,基于目标程序语句访问的数组的预定变量在所述数组对应的程序区域内的值范围,对程序代码中是否包含数组越界访问进行检测,这样,通过对函数之间的调用关系信息中的程序语句的检测,来确定程序代码中是否包含数组越界访问,因此,可以使得该检测过程可以覆盖该程序代码的所有执行路径,提高了检测的准确性,此外,通过对函数之间的调用关系信息中的程序语句的检测和获取数组的预定变量在该数组对应的程序区域内的值范围,来进一步对程序代码中是否包含数组越界访问进行检测,可以使得数组越界访问的检测效率更高。The embodiments of this specification provide a method for detecting array out-of-bounds access. By acquiring functions included in the program code to be detected, and calling relationship information between the functions, if the calling relationship information between the functions includes unaccessed If the target program statement needs to access the array, then obtain the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array, based on the target program statement The value range of the predetermined variable of the accessed array in the program area corresponding to the array is detected, whether the program code contains array out-of-bounds access, so that by detecting the program statement in the calling relationship information between functions, It is determined whether the program code contains array out-of-bounds access. Therefore, the detection process can cover all execution paths of the program code, and the detection accuracy is improved. Detecting and obtaining the value range of the predetermined variable of the array in the program area corresponding to the array to further detect whether the program code includes out-of-bounds access to the array can make the detection of out-of-bounds access to the array more efficient.
实施例二
如图2所示,本说明书实施例提供一种数组越界访问的检测方法,该方法的执行主体可以为终端设备或服务器,其中,该终端设备可以如手机、平板电脑等,该服务器可以是一个独立的服务器,还可以是由多个服务器构成的服务器集群等。该服务器可以是某项业务(如进行交易的业务等)的后台服务器,也可以是某应用(如金融类应用等)的后台服务器等。该方法具体可以包括以下步骤:As shown in FIG. 2 , an embodiment of this specification provides a method for detecting out-of-bounds access to an array. The execution body of the method may be a terminal device or a server, wherein the terminal device may be a mobile phone, a tablet computer, etc., and the server may be a An independent server may also be a server cluster composed of multiple servers, or the like. The server may be a background server of a certain business (such as a transaction business, etc.), or a background server of a certain application (such as a financial application, etc.). The method may specifically include the following steps:
在步骤S202中,将待检测的程序代码转换为预定表达形式的程序代码。In step S202, the program code to be detected is converted into a program code in a predetermined expression form.
其中,预定表达形式可以是预先设定的任意一种表达形式,即可以将同一事物的多种不同表达方式统一为预定表达形式。The predetermined expression form may be any preset expression form, that is, multiple different expression modes of the same thing may be unified into a predetermined expression form.
在实施中,为了后续处理过程简单易行,可以将待检测的程序代码转换为统一的预定表达形式的程序代码,这样,同一事物可以具有相同的表达方式,便于后续的程序代码处理。例如,对于待检测的程序代码中是否存在数组越界访问,可以将涉及的数组转换为统一的表达形式,例如,数组可以统一表示为base[subscript.1][subscript.2]…[subscript.N]形式,其中,base为一个n维数组,n为正整数,subscript.1~subscript.N为每一维数组的下标。In implementation, in order to simplify the subsequent processing process, the program code to be detected can be converted into a program code of a unified predetermined expression form, so that the same thing can have the same expression mode, which is convenient for subsequent program code processing. For example, for whether there is an array out-of-bounds access in the program code to be detected, the involved array can be converted into a unified expression form, for example, the array can be expressed as base[subscript.1][subscript.2]…[subscript.N ] form, where base is an n-dimensional array, n is a positive integer, and subscript.1 to subscript.N are the subscripts of each dimensional array.
在步骤S204中,获取转换为预定表达形式的程序代码中包含的函数。In step S204, the functions contained in the program code converted into a predetermined expression form are acquired.
在实施中,由于待检测的程序代码被转换为统一的表达形式,因此,可以通过设定关键词和/或结构格式等方式来表征不同的函数,这样,当得到转换为预定表达形式的程序代码后,可以基于不同函数对应的关键词和/或结构格式,确定转换为预定表达形式的程序代码中包含哪些函数,从而可以得到转换为预定表达形式的程序代码中包含的函数。In implementation, since the program code to be detected is converted into a unified expression form, different functions can be represented by setting keywords and/or structural formats, so that when a program converted into a predetermined expression form is obtained After coding, based on the keywords and/or structure formats corresponding to different functions, it can be determined which functions are included in the program code converted into the predetermined expression form, so that the functions included in the program code converted into the predetermined expression form can be obtained.
在步骤S206中,对转换后的程序代码中包含的函数的程序语句的结构进行识别,得到识别结果。In step S206, the structure of the program statement of the function included in the converted program code is recognized, and the recognition result is obtained.
在实施中,为了确定程序语句中包含的变量,需要对转换后的程序代码中包含的函数的程序语句的结构进行识别,从而确定该函数的程序语句中包含哪些特定语句(如循环语句或分支语句等),为此,可以预先设定程序语句的识别机制,该识别机制可以通过多种方式设定,例如,可以根据不同特定语句中的特征或特点设置该识别机制,如可以获取特征语句中包含的特定关键字、关键词或关键字段等,并可以设定特定语句的结构特征或结构特点,然后,基于特定关键字、关键词或关键字段,以及结构特征或结构特点设定该识别机制。然后,可以将该函数的程序语句与该识别机制中的关键字、关键词或关键字段,以及结构特征或结构特点进行匹配,得到匹配结果即可以为识别结果。In implementation, in order to determine the variables contained in the program statement, it is necessary to identify the structure of the program statement of the function contained in the converted program code, so as to determine which specific statements (such as loop statements or branches) are contained in the program statements of the function. Statements, etc.), for this purpose, the recognition mechanism of program statements can be preset, and the recognition mechanism can be set in various ways. For example, the recognition mechanism can be set according to the characteristics or characteristics of different specific statements. For example, characteristic statements can be obtained. Specific keywords, keywords or key fields, etc. contained in the statement, and can set the structural characteristics or structural characteristics of specific statements, and then set based on specific keywords, keywords or key fields, and structural characteristics or structural characteristics the identification mechanism. Then, the program statement of the function can be matched with keywords, keywords or key fields, and structural features or structural features in the identification mechanism, and a matching result can be obtained as the identification result.
在步骤S208中,如果上述识别结果指示上述函数的程序语句为循环语句,则获取该函数的程序语句对应的循环归纳变量和循环体。In step S208, if the identification result indicates that the program statement of the function is a loop statement, the loop induction variable and loop body corresponding to the program statement of the function are acquired.
在实施中,程序语句的识别机制可以识别函数的程序语句的结构,如果识别的结果为循环语句,则可以识别该函数中的循环结构和循环结构中使用的循环归纳变量或自增、自减变量,并可以确定循环入口、循环出口和循环体,以及归纳变量的初始值、终止条件和循环步长等。In the implementation, the identification mechanism of the program statement can identify the structure of the program statement of the function, and if the result of the identification is a loop statement, it can identify the loop structure in the function and the loop induction variable used in the loop structure or self-increment, self-decrement Variables, and can determine the loop entry, loop exit and loop body, as well as the initial value of the induction variable, termination conditions and loop step size.
在步骤S210中,确定循环归纳变量在循环体内的值范围。In step S210, the value range of the loop induction variable in the loop body is determined.
在实施中,还可以预先设定变量值范围分析机制,可以通过变量值范围分析机制分析函数内的程序语句的判断条件,确定变量在不同分支区域内的取值范围,利用循环分析的结果确定变量在不同区域内的取值范围。不同类型的循环语句,上述步骤S208和步骤S210的具体处理可以不同,例如:In the implementation, the variable value range analysis mechanism can also be preset, and the judgment conditions of the program statements in the function can be analyzed through the variable value range analysis mechanism to determine the value range of the variable in different branch regions, and the result of the loop analysis can be used to determine The value range of the variable in different regions. For different types of loop statements, the specific processing of the above steps S208 and S210 may be different, for example:
如图3所示,其中的循环语句为规则循环语句,则可以基于程序语句的识别机制识别该函数中的循环入口、循环回边、循环出口和循环体等,并还可以识别循环归纳变量为I,存在初值、约束条件和自增赋值,循环次数为(end-start)/step。变量值范围分析机制可以确定循环归纳变量I在循环体内的值范围为[start,end),并可以确定循环归纳变量I在离开循环后值范围为(start+((end-start)/step+1)*step)。As shown in Figure 3, where the loop statement is a regular loop statement, the loop entry, loop back edge, loop exit and loop body in the function can be identified based on the identification mechanism of the program statement, and the loop induction variable can also be identified as I, there are initial values, constraints and self-increasing assignments, and the number of loops is (end-start)/step. The variable value range analysis mechanism can determine that the value range of the loop induction variable I in the loop body is [start, end), and can determine that the value range of the loop induction variable I after leaving the loop is (start+((end-start)/step+1 )*step).
如图4所示,其中的循环语句为可提前终止循环语句,则可以基于程序语句的识别机制识别该函数中的循环入口、循环出口和循环体,并可以识别出该循环语句可提前终止等,并还可以识别循环归纳变量为I,存在初值、约束条件和自增赋值,循环次数为(end-start)/step。变量值范围分析机制可以确定循环归纳变量I在循环体内的值范围为[start,end),并可以确定循环归纳变量I在离开循环后值范围为[start,(start+((end-start)/step+1)*step)),或近似为[start,end+step]。As shown in Figure 4, where the loop statement is a loop statement that can be terminated early, the loop entry, loop exit and loop body in the function can be identified based on the identification mechanism of the program statement, and it can be identified that the loop statement can be terminated early, etc. , and can also recognize that the loop induction variable is I, there are initial values, constraints and self-increasing assignments, and the number of loops is (end-start)/step. The variable value range analysis mechanism can determine that the value range of the loop induction variable I in the loop body is [start, end), and can determine that the value range of the loop induction variable I after leaving the loop is [start, (start+((end-start)/ step+1)*step)), or approximately [start,end+step].
如图5所示,其中的循环语句为无循环归纳变量循环语句,则可以基于程序语句的识别机制识别该函数中的循环入口、循环出口和循环体等,并还可以识别自增/自减变量为I,由于循环终止条件不包含I,因此,该循环语句中无归纳变量,且循环次数未知。变量值范围分析机制可以确定自增变量I赋初值前值范围为(I_min,I_max),可以确定I在循环体内的值范围为[start,I_max),并可以确定循环归纳变量I在离开循环后值范围为[start,I_max)。As shown in Figure 5, where the loop statement is a loop-free induction variable loop statement, the loop entry, loop exit, loop body, etc. in the function can be identified based on the identification mechanism of the program statement, and self-increment/self-decrement can also be identified. The variable is I. Since the loop termination condition does not contain I, there is no induction variable in the loop statement, and the number of loops is unknown. The variable value range analysis mechanism can determine that the value range of the self-increasing variable I before assigning the initial value is (I_min, I_max), the value range of I in the loop body is [start, I_max), and the loop induction variable I can be determined to leave the loop. The range of post values is [start, I_max).
在步骤S212中,如果上述识别结果指示上述函数的程序语句为IF分支语句,则获取该函数的程序语句对应的THEN语句块、ELSE语句块和条件判断变量。In step S212, if the identification result indicates that the program statement of the function is an IF branch statement, the THEN statement block, the ELSE statement block and the condition judgment variable corresponding to the program statement of the function are obtained.
在实施中,程序语句的识别机制可以识别函数的程序语句的结构,如果识别的结果为IF分支语句,则可以识别该函数中的分支结构和分支结构中使用的THEN语句块、ELSE语句块和条件判断变量等。In implementation, the identification mechanism of the program statement can identify the structure of the program statement of the function, and if the identified result is an IF branch statement, the branch structure in the function and the THEN statement block, ELSE statement block and the THEN statement block used in the branch structure can be identified. Conditional judgment variables, etc.
在步骤S214中,分别确定条件判断变量在THEN语句块内的值范围和在ELSE语句块内的值范围。In step S214, the value range of the condition judgment variable in the THEN statement block and the value range in the ELSE statement block are respectively determined.
在实施中,还可以通过变量值范围分析机制分析函数内的分支语句的判断条件确定变量在分支不同区域内的取值范围,利用循环分析的结果确定变量在循环不同区域内的取值范围。不同类型的IF分支语句,上述步骤S208和步骤S210的具体处理可以不同,例如:In implementation, the variable value range analysis mechanism can also analyze the judgment condition of the branch statement in the function to determine the value range of the variable in different areas of the branch, and use the result of the loop analysis to determine the value range of the variable in the different areas of the loop. For different types of IF branch statements, the specific processing of the above steps S208 and S210 may be different, for example:
如图6所示,其中的分支语句为IF分支语句,则可以基于程序语句的识别机制识别该函数中的THEN语句块、ELSE语句块和条件判断变量I等。若条件判断变量I在IF分支语句前值范围为(I_min,I_max),则确定I在THEN语句块内值范围为(I_min,cond),在ELSE语句块内值范围为[cond,I_max)。As shown in FIG. 6 , where the branch statement is an IF branch statement, then the THEN statement block, the ELSE statement block and the condition judgment variable I etc. in the function can be identified based on the identification mechanism of the program statement. If the conditional judgment variable I has a value range of (I_min, I_max) before the IF branch statement, it is determined that the value range of I in the THEN statement block is (I_min, cond), and the value range in the ELSE statement block is [cond, I_max).
如图7所示,其中的分支语句为嵌套IF分支语句,则可以基于程序语句的识别机制识别该函数中的THEN语句块、ELSE语句块和条件判断变量I等。具体地,可以识别出顶层IF分支结构、其中的THEN语句块1、ELSE语句块1和条件判断变量I,也可以是识别出THEN语句块内的IF分支结构,其中的THEN语句块2、ELSE语句块2和条件判断变量I,还可以识别出ELSE语句块内的IF分支结构,其中的THEN语句块3,ELSE语句块3和条件判断变量I等。As shown in FIG. 7 , where the branch statement is a nested IF branch statement, then the THEN statement block, the ELSE statement block and the condition judgment variable I etc. in the function can be identified based on the identification mechanism of the program statement. Specifically, the top-level IF branch structure, the
其中,若条件判断变量I在IF分支语句前值范围为(I_min,I_max),则确定I在THEN语句块1内值范围为(I_min,cond_1),在ELSE语句块1内值范围为[cond_1,I_max)。可以确定I在THEN语句块2内值为(cond_2),在ELSE语句块内值范围为(I_min,cond_2)U(cond_2,cond_1)。可以确定I在THEN语句块3内值范围为(cond_3,I_max),在ELSE语句块内值范围为[cond_1,cond_3]。Among them, if the conditional judgment variable I has a value range of (I_min, I_max) before the IF branch statement, it is determined that the value range of I in THEN
在步骤S216中,如果识别结果指示上述函数的程序语句为SWITCH选择语句,则获取该函数的程序语句对应的CASE语句值及其对应的CASE语句块、DEFAULT语句块和选择变量。In step S216, if the identification result indicates that the program statement of the function is a SWITCH selection statement, the CASE statement value corresponding to the program statement of the function and its corresponding CASE statement block, DEFAULT statement block and selection variable are obtained.
在实施中,程序语句的识别机制可以识别函数的程序语句的结构,如果识别的结果为SWITCH选择语句,则可以识别该函数中的CASE语句值及其的SWITCH选择语句等。In implementation, the identification mechanism of the program statement can identify the structure of the program statement of the function, and if the identified result is a SWITCH option statement, it can identify the CASE statement value in the function and its SWITCH option statement.
在步骤S218中,确定选择变量在每个CASE语句块内的值范围和在DEFAULT语句块内的值范围。In step S218, the value range of the selection variable in each CASE statement block and the value range in the DEFAULT statement block are determined.
在实施中,如图8所示,其中的选择语句为SWITCH选择语句,则可以基于程序语句的识别机制识别该函数中的CASE语句值及对应的CASE语句块,以及DEFAULT语句块和选择变量I等。可以设定每个CASE语句块内I的值范围为其对应的CASE语句值,并设定DEFAULT语句块内I的值范围为进入SWITCH选择结构前I的值范围去除所有CASE语句值的剩余集合。In the implementation, as shown in FIG. 8 , where the selection statement is a SWITCH selection statement, the CASE statement value and the corresponding CASE statement block in the function, as well as the DEFAULT statement block and the selection variable I can be identified based on the identification mechanism of the program statement. Wait. You can set the value range of I in each CASE statement block to its corresponding CASE statement value, and set the value range of I in the DEFAULT statement block to the value range of I before entering the SWITCH selection structure. Remove the remaining set of all CASE statement values. .
此外,除了可以执行上述处理得到变量值范围时,还可以获取函数内变量使用和定义的关系,具体可以通过预先设定的函数内变量使用定义分析机制分析函数内变量使用和定义的关系,从而建立使用-定义关系信息(在实际应用中可以是关系链),这样,可以使得对函数内每一个变量的使用都能沿着关系链溯源到变量的定义,该变量的定义可以来自于全局变量、函数的形式参数或函数调用的其他函数的返回值等。In addition, in addition to the above processing to obtain the variable value range, the relationship between the use and definition of variables in the function can also be obtained. Specifically, the relationship between the use and definition of variables in the function can be analyzed through the pre-set variable use definition analysis mechanism in the function. Establish use-definition relationship information (in practical applications, it can be a relationship chain), so that the use of each variable in the function can be traced to the definition of the variable along the relationship chain, and the definition of the variable can come from global variables , the formal parameters of the function, or the return value of other functions called by the function, etc.
上述是对函数内的程序语句进行分析从而确定函数中的变量值范围,在实际应用中,还可以对函数之间的关系进行分析,具体可以参见下述步骤S220~步骤S224的处理。The above is to analyze the program statement in the function to determine the variable value range in the function. In practical application, the relationship between the functions can also be analyzed. For details, please refer to the following steps S220 to S224.
在步骤S220中,对上述函数之间的调用关系进行分析,得到函数调用图谱,该函数调用图谱中包括多个函数和多个函数之间的连接线。In step S220, the calling relationship between the above functions is analyzed to obtain a function calling graph, where the function calling graph includes multiple functions and connecting lines between the multiple functions.
在实施中,可以预先设定函数调用关系分析机制,该函数调用关系分析机制可以分析函数相互间的调用关系,生成函数调用图谱,该函数调用图谱中包括多个函数和多个函数之间表征调用关系的连接线,函数调用图谱上每一个节点可以为一个函数,每一条连接线(或边)可以为一个调用点。In implementation, a function call relationship analysis mechanism can be preset, and the function call relationship analysis mechanism can analyze the call relationship between functions to generate a function call graph, where the function call graph includes multiple functions and representations between multiple functions The connection line of the call relationship, each node on the function call graph can be a function, and each connection line (or edge) can be a call point.
在步骤S222中,将函数调用图谱中的函数的形式参数与该函数在函数调用图谱中的实际参数相连接,得到参数连接信息。In step S222, the formal parameters of the function in the function call graph are connected with the actual parameters of the function in the function call graph to obtain parameter connection information.
在实施中,还可以预先设定函数调用实际参数和形式参数分析机制,通过函数调用实际参数和形式参数分析机制可以建立辅助数据结构,以将函数的形式参数与该函数在每一个调用点的实际参数相连接,从而得到参数连接信息。In the implementation, the actual parameters of the function call and the formal parameter analysis mechanism can also be preset, and an auxiliary data structure can be established through the actual parameters of the function call and the formal parameter analysis mechanism to associate the formal parameters of the function with the function at each call point. The actual parameters are connected to obtain parameter connection information.
在步骤S224中,获取预定的全局变量在函数调用图谱中各个函数之间的使用和定义关系,得到全局变量使用定义连接信息。In step S224, the usage and definition relationship between the functions in the function call graph of the predetermined global variable is acquired, and the connection information of the usage definition of the global variable is obtained.
在实施中,还可以预先设定函数间全局变量定义使用分析机制,通过函数间全局变量定义使用分析机制分析全局变量在各个函数间的使用与定义的关系,将跨函数的全局变量的使用和定义相连接。参数、返回值和全局变量使用和定义的连接信息可以存储在预定的附加数据表中,该数据表可以以标注的形式标注在函数调用图谱的每条连接线上,函数调用图谱及连接线上的标注可如图9所示。In the implementation, the definition and usage analysis mechanism of global variables between functions can also be preset, and the relationship between the usage and definition of global variables between functions can be analyzed through the usage analysis mechanism of global variable definitions among functions, and the usage and definitions of global variables across functions can be compared with each other. Define the connection. The connection information used and defined for parameters, return values and global variables can be stored in a predetermined additional data table. The labeling can be shown in Figure 9.
此外,还可以预先设定路径跟踪机制,通过路径跟踪机制可以记录在进行程序代码分析的过程中,对于循环、分支或函数调用时选择的路径信息,通过路径跟踪机制可以避免循环、分支或函数被遗漏或重复访问,确保跨函数分析后能回到正确的函数调用点。In addition, the path tracking mechanism can also be preset, and the path tracking mechanism can be used to record the path information selected during the process of program code analysis for loops, branches or function calls. The path tracking mechanism can avoid loops, branches or functions. Missed or repeated visits ensure that cross-function analysis returns to the correct function call site.
在步骤S226中,检测函数之间的调用关系信息中是否包括未被访问的函数。In step S226, it is detected whether the calling relationship information between functions includes functions that have not been accessed.
在实施中,为了提高处理效率,可以先遍历函数调用图谱(即函数之间的调用关系信息)中的每一个函数的访问记录,以确定函数调用图谱中是否包括未被访问的函数。In implementation, in order to improve processing efficiency, the access records of each function in the function call graph (that is, the call relationship information between functions) may be traversed first to determine whether the function call graph includes unvisited functions.
在步骤S228中,如果函数之间的调用关系信息中包括未被访问的函数,则将未被访问的函数中的程序语句作为目标程序语句。In step S228, if the calling relationship information between functions includes an unvisited function, the program statement in the unvisited function is used as the target program statement.
在实施中,如果函数之间的调用关系信息(即函数调用图谱)中包括未被访问的函数,则表明在函数中的程序语句均未被访问,则该函数中的程序语句作为目标程序语句。In implementation, if the calling relationship information between functions (that is, the function call graph) includes an unvisited function, it means that none of the program statements in the function have been accessed, and the program statement in the function is used as the target program statement .
在步骤S230中,如果函数之间的调用关系信息中不包括未被访问的函数,则检测函数之间的调用关系信息中是否包括未被访问的目标程序语句。In step S230, if the calling relationship information between functions does not include unvisited functions, it is detected whether the calling relation information between functions includes unvisited target program statements.
在步骤S232中,如果函数之间的调用关系信息中包括未被访问的目标程序语句,则检测目标程序语句是否需要访问数组。In step S232, if the calling relationship information between functions includes the target program statement that has not been accessed, it is detected whether the target program statement needs to access the array.
在实施中,对于每个目标程序语句,可以识别出其中是否包含预定的数组访问结构,如base[subscript.1][subscript.2]…[subscript.N],如果识别出某目标程序语句中包含预定的数组访问结构(如base[subscript.1][subscript.2]…[subscript.N]等),则可以对每一个数据访问结构,先沿着数组的使用定义关系信息(如使用定义关系链)找到该数组所有的定义,即执行下述步骤S234的处理。In implementation, for each target program statement, it can be identified whether it contains a predetermined array access structure, such as base[subscript.1][subscript.2]...[subscript.N], if it is identified that a certain target program statement contains a predetermined array access structure Contains a predetermined array access structure (such as base[subscript.1][subscript.2]...[subscript.N], etc.), then for each data access structure, first define the relationship information along the use of the array (such as use definition relationship chain) to find all definitions of the array, that is, execute the processing of the following step S234.
在步骤S234中,如果目标程序语句需要访问数组,则根据预定的使用定义关系信息,确定目标程序语句访问的数组的定义。In step S234, if the target program statement needs to access the array, the definition of the array accessed by the target program statement is determined according to the predetermined usage definition relationship information.
其中,使用定义关系信息可以通过上述函数内变量使用定义分析机制确定,具体处理可以参见上述相关内容,在此不再赘述。The usage definition relationship information can be determined through the above-mentioned variable usage definition analysis mechanism in the function, and the specific processing can refer to the above-mentioned related content, which will not be repeated here.
在步骤S236中,根据预定的使用定义关系信息和目标程序语句访问的数组的定义对应的记录信息,查询目标程序语句访问的数组中每一维预定变量在该数组对应的程序区域内的值范围。In step S236, according to the predetermined usage definition relationship information and the record information corresponding to the definition of the array accessed by the target program statement, query the value range of each dimension of the predetermined variable in the array accessed by the target program statement in the program area corresponding to the array .
在实施中,对每一个数组的定义,可以获得该定义下的数组对应的每一维度的大小,并将目标程序语句访问的数组的定义的路径通过路径跟踪机制进行记录,然后,可以根据数组的使用的定义的路径查找各个预定变量在该路径经过的程序区域内的值范围。In the implementation, for the definition of each array, the size of each dimension corresponding to the array under the definition can be obtained, and the defined path of the array accessed by the target program statement is recorded through the path tracking mechanism, and then, according to the array The defined path used finds the value range of each predetermined variable in the program area that the path passes through.
在步骤S238中,基于目标程序语句访问的数组的预定变量在该数组对应的程序区域内的值范围,对该程序代码中是否包含数组越界访问进行检测。In step S238, based on the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array, it is detected whether the program code includes array out-of-bounds access.
在实施中,可以将目标程序语句访问的数组的预定变量在该数组对应的程序区域内的值范围与该数组对应的维数的大小进行比较,如果数组的预定变量在该数组对应的程序区域内的值范围超过了该数组对应的维数的大小,则可以确定数组越界访问错误并可以输出路径跟踪信息。In implementation, the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array can be compared with the size of the dimension corresponding to the array. If the predetermined variable of the array is in the program area corresponding to the array If the value range in the array exceeds the size of the corresponding dimension of the array, the array out-of-bounds access error can be determined and the path tracking information can be output.
需要说明的是,上述处理过程中,每个函数和每个程序语句仅被访问一次,在检查每个数组的访问时,可以沿着使用定义关系信息查找相应数组的定义,使用定义关系信息的长度通常具有固定长度上界。在沿着数组的定义的路径验证预定变量是否在数组对应的程序区域内的值范围内时,也仅需查询少于路径长度的语句块,因此上述处理过程的时间复杂度可以认为是线性的。It should be noted that, in the above processing process, each function and each program statement are accessed only once. When checking the access of each array, you can find the definition of the corresponding array along the use of the definition relationship information, and use the definition relationship information to find the definition of the corresponding array. The length usually has a fixed upper bound on the length. When verifying whether the predetermined variable is within the value range of the program area corresponding to the array along the defined path of the array, only the statement block less than the length of the path needs to be queried, so the time complexity of the above process can be considered as linear .
本说明书实施例提供一种数组越界访问的检测方法,通过获取待检测的程序代码中包含的函数,以及该函数之间的调用关系信息,如果该函数之间的调用关系信息中包括未被访问的目标程序语句,则检测目标程序语句是否需要访问数组,如果目标程序语句需要访问数组,则获取目标程序语句访问的数组的预定变量在该数组对应的程序区域内的值范围,基于目标程序语句访问的数组的预定变量在所述数组对应的程序区域内的值范围,对程序代码中是否包含数组越界访问进行检测,这样,通过对函数之间的调用关系信息中的程序语句的检测,来确定程序代码中是否包含数组越界访问,因此,可以使得该检测过程可以覆盖该程序代码的所有执行路径,提高了检测的准确性,此外,通过对函数之间的调用关系信息中的程序语句的检测和获取数组的预定变量在该数组对应的程序区域内的值范围,来进一步对程序代码中是否包含数组越界访问进行检测,可以使得数组越界访问的检测效率更高。The embodiments of this specification provide a method for detecting array out-of-bounds access. By acquiring functions included in the program code to be detected, and calling relationship information between the functions, if the calling relationship information between the functions includes unaccessed If the target program statement needs to access the array, then obtain the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array, based on the target program statement The value range of the predetermined variable of the accessed array in the program area corresponding to the array is detected, whether the program code contains array out-of-bounds access, so that by detecting the program statement in the calling relationship information between functions, It is determined whether the program code contains array out-of-bounds access. Therefore, the detection process can cover all execution paths of the program code, and the detection accuracy is improved. Detecting and obtaining the value range of the predetermined variable of the array in the program area corresponding to the array to further detect whether the program code includes out-of-bounds access to the array can make the detection of out-of-bounds access to the array more efficient.
实施例三Embodiment 3
以上为本说明书实施例提供的数组越界访问的检测方法,基于同样的思路,本说明书实施例还提供一种数组越界访问的检测装置,如图10所示。The method for detecting array out-of-bounds access provided by the above embodiments of this specification is based on the same idea, and an embodiment of this specification also provides a detection device for out-of-bounds access to an array, as shown in FIG. 10 .
该数组越界访问的检测装置包括:信息获取模块1001、数组访问检测模块1002、值范围获取模块1003和越界访问检测模块1004,其中:The detection device for array out-of-bounds access includes: an
信息获取模块1001,用于获取待检测的程序代码中包含的函数,以及所述函数之间的调用关系信息;The
数组访问检测模块1002,用于如果所述函数之间的调用关系信息中包括未被访问的目标程序语句,则检测所述目标程序语句是否需要访问数组;an array
值范围获取模块1003,用于如果所述目标程序语句需要访问数组,则获取所述目标程序语句访问的数组的预定变量在所述数组对应的程序区域内的值范围;A value
越界访问检测模块1004,用于基于所述目标程序语句访问的数组的预定变量在所述数组对应的程序区域内的值范围,对所述程序代码中是否包含数组越界访问进行检测。The out-of-bounds
本说明书实施例中,所述装置还包括:In the embodiment of this specification, the device further includes:
函数检测模块,用于检测所述函数之间的调用关系信息中是否包括未被访问的函数;a function detection module, configured to detect whether the calling relationship information between the functions includes unvisited functions;
函数检测结果模块,用于如果所述函数之间的调用关系信息中包括未被访问的函数,则将所述未被访问的函数中的程序语句作为所述目标程序语句;A function detection result module, configured to use the program statement in the unvisited function as the target program statement if the calling relationship information between the functions includes an unvisited function;
语句检测模块,用于如果所述函数之间的调用关系信息中不包括未被访问的函数,则检测所述函数之间的调用关系信息中是否包括未被访问的目标程序语句。A statement detection module, configured to detect whether the calling relationship information between the functions includes an unvisited target program statement if the calling relationship information between the functions does not include an unvisited function.
本说明书实施例中,所述装置还包括:In the embodiment of this specification, the device further includes:
转换模块,用于将所述待检测的程序代码转换为预定表达形式的程序代码;a conversion module for converting the program code to be detected into a program code of a predetermined expression form;
所述信息获取模块,用于获取转换为预定表达形式的程序代码中包含的函数,以及所述函数之间的调用关系信息。The information acquisition module is used for acquiring the functions contained in the program code converted into a predetermined expression form, and the calling relationship information between the functions.
本说明书实施例中,所述装置还包括:In the embodiment of this specification, the device further includes:
识别模块,用于对转换后的程序代码中包含的函数的程序语句的结构进行识别,得到识别结果;The identification module is used to identify the structure of the program statement of the function contained in the converted program code, and obtain the identification result;
第一语句处理模块,用于如果所述识别结果指示所述函数的程序语句为循环语句,则获取所述函数的程序语句对应的循环归纳变量和循环体;a first statement processing module, configured to acquire a loop induction variable and a loop body corresponding to the program statement of the function if the identification result indicates that the program statement of the function is a loop statement;
第一值范围确定模块,用于确定所述循环归纳变量在所述循环体内的值范围。The first value range determination module is used for determining the value range of the loop induction variable in the loop body.
本说明书实施例中,所述装置还包括:In the embodiment of this specification, the device further includes:
第二语句处理模块,用于如果所述识别结果指示所述函数的程序语句为IF分支语句,则获取所述函数的程序语句对应的THEN语句块、ELSE语句块和条件判断变量;The second statement processing module is used to obtain the THEN statement block, the ELSE statement block and the condition judgment variable corresponding to the program statement of the function if the recognition result indicates that the program statement of the function is an IF branch statement;
第二值范围确定模块,用于分别确定所述条件判断变量在所述THEN语句块内的值范围和在所述ELSE语句块内的值范围。The second value range determination module is configured to respectively determine the value range of the condition judgment variable in the THEN statement block and the value range in the ELSE statement block.
本说明书实施例中,所述装置还包括:In the embodiment of this specification, the device further includes:
第三语句处理模块,用于如果所述识别结果指示所述函数的程序语句为SWITCH选择语句,则获取所述函数的程序语句对应的CASE语句值及其对应的CASE语句块、DEFAULT语句块和选择变量;A third statement processing module, configured to acquire the CASE statement value corresponding to the program statement of the function and its corresponding CASE statement block, DEFAULT statement block and select variable;
第三值范围确定模块,用于确定所述选择变量在每个CASE语句块内的值范围和在所述DEFAULT语句块内的值范围。The third value range determination module is used for determining the value range of the selection variable in each CASE statement block and the value range in the DEFAULT statement block.
本说明书实施例中,所述信息获取模块1001,包括:In the embodiment of this specification, the
调用图确定单元,用于对所述函数之间的调用关系进行分析,得到函数调用图谱,所述函数调用图谱中包括多个函数和所述多个函数之间的连接线;a call graph determination unit, configured to analyze the calling relationship between the functions to obtain a function call graph, where the function call graph includes multiple functions and connecting lines between the multiple functions;
参数连接确定单元,用于将所述函数调用图谱中的函数的形式参数与所述函数在所述函数调用图谱中的实际参数相连接,得到参数连接信息;a parameter connection determination unit, configured to connect the formal parameters of the function in the function call map with the actual parameters of the function in the function call map to obtain parameter connection information;
连接信息确定单元,用于获取预定的全局变量在所述函数调用图谱中各个函数之间的使用和定义关系,得到全局变量使用定义连接信息。The connection information determination unit is configured to acquire the usage and definition relationship between the functions of the predetermined global variables in the function call graph, and obtain the usage definition connection information of the global variables.
本说明书实施例中,所述值范围获取模块1003,包括:In the embodiment of this specification, the value
定义确定单元,用于如果所述目标程序语句需要访问数组,则根据预定的使用定义关系信息,确定所述目标程序语句访问的数组的定义;A definition determining unit is used to determine the definition of the array accessed by the target program statement according to predetermined use definition relationship information if the target program statement needs to access the array;
值范围获取单元,用于根据预定的使用定义关系信息和所述目标程序语句访问的数组的定义对应的记录信息,查询所述目标程序语句访问的数组中每一维预定变量在所述数组对应的程序区域内的值范围。The value range acquisition unit is used to query the corresponding record information of each dimension of the array accessed by the target program statement according to the predetermined use definition relationship information and the corresponding record information of the definition of the array accessed by the target program statement. range of values within the program area of .
本说明书实施例提供一种数组越界访问的检测装置,通过获取待检测的程序代码中包含的函数,以及该函数之间的调用关系信息,如果该函数之间的调用关系信息中包括未被访问的目标程序语句,则检测目标程序语句是否需要访问数组,如果目标程序语句需要访问数组,则获取目标程序语句访问的数组的预定变量在该数组对应的程序区域内的值范围,基于目标程序语句访问的数组的预定变量在所述数组对应的程序区域内的值范围,对程序代码中是否包含数组越界访问进行检测,这样,通过对函数之间的调用关系信息中的程序语句的检测,来确定程序代码中是否包含数组越界访问,因此,可以使得该检测过程可以覆盖该程序代码的所有执行路径,提高了检测的准确性,此外,通过对函数之间的调用关系信息中的程序语句的检测和获取数组的预定变量在该数组对应的程序区域内的值范围,来进一步对程序代码中是否包含数组越界访问进行检测,可以使得数组越界访问的检测效率更高。An embodiment of the present specification provides a detection device for out-of-bounds access to an array. By acquiring the functions contained in the program code to be detected, and the calling relationship information between the functions, if the calling relationship information between the functions includes unaccessed If the target program statement needs to access the array, then obtain the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array, based on the target program statement The value range of the predetermined variable of the accessed array in the program area corresponding to the array is detected, whether the program code contains array out-of-bounds access, so that by detecting the program statement in the calling relationship information between functions, It is determined whether the program code contains array out-of-bounds access. Therefore, the detection process can cover all execution paths of the program code, and the detection accuracy is improved. Detecting and obtaining the value range of the predetermined variable of the array in the program area corresponding to the array to further detect whether the program code includes out-of-bounds access to the array can make the detection of out-of-bounds access to the array more efficient.
实施例四Embodiment 4
以上为本说明书实施例提供的数组越界访问的检测装置,基于同样的思路,本说明书实施例还提供一种数组越界访问的检测设备,如图11所示。The detection device for out-of-bounds access of an array provided in the above embodiments of the present specification is based on the same idea, and an embodiment of the present specification also provides a detection device for out-of-bounds access of an array, as shown in FIG. 11 .
所述数组越界访问的检测设备可以为上述实施例提供的服务器。The detection device for out-of-bounds access to the array may be the server provided in the above embodiment.
数组越界访问的检测设备可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上的处理器1101和存储器1102,存储器1102中可以存储有一个或一个以上存储应用程序或数据。其中,存储器1102可以是短暂存储或持久存储。存储在存储器1102的应用程序可以包括一个或一个以上模块(图示未示出),每个模块可以包括对数组越界访问的检测设备中的一系列计算机可执行指令。更进一步地,处理器1101可以设置为与存储器1102通信,在数组越界访问的检测设备上执行存储器1102中的一系列计算机可执行指令。数组越界访问的检测设备还可以包括一个或一个以上电源1103,一个或一个以上有线或无线网络接口1104,一个或一个以上输入输出接口1105,一个或一个以上键盘1106。The detection device for array out-of-bounds access may vary greatly due to different configurations or performance, and may include one or
具体在本实施例中,数组越界访问的检测设备包括有存储器,以及一个或一个以上的程序,其中一个或者一个以上程序存储于存储器中,且一个或者一个以上程序可以包括一个或一个以上模块,且每个模块可以包括对数组越界访问的检测设备中的一系列计算机可执行指令,且经配置以由一个或者一个以上处理器执行该一个或者一个以上程序包含用于进行以下计算机可执行指令:Specifically in this embodiment, the detection device for array out-of-bounds access includes a memory, and one or more programs, wherein one or more programs are stored in the memory, and one or more programs may include one or more modules, And each module may include a series of computer-executable instructions in a device for detecting out-of-bounds access to an array, and the one or more programs configured to be executed by one or more processors include computer-executable instructions for performing the following:
获取待检测的程序代码中包含的函数,以及所述函数之间的调用关系信息;Obtain the functions contained in the program code to be detected, and the calling relationship information between the functions;
如果所述函数之间的调用关系信息中包括未被访问的目标程序语句,则检测所述目标程序语句是否需要访问数组;If the calling relationship information between the functions includes an unvisited target program statement, then detect whether the target program statement needs to access an array;
如果所述目标程序语句需要访问数组,则获取所述目标程序语句访问的数组的预定变量在所述数组对应的程序区域内的值范围;If the target program statement needs to access the array, then obtain the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array;
基于所述目标程序语句访问的数组的预定变量在所述数组对应的程序区域内的值范围,对所述程序代码中是否包含数组越界访问进行检测。Based on the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array, it is detected whether the program code includes out-of-bounds access to the array.
本说明书实施例中,所述获取待检测的程序代码中包含的函数,以及所述函数之间的调用关系信息之后,还包括:In the embodiment of the present specification, after acquiring the functions included in the program code to be detected and the calling relationship information between the functions, the method further includes:
检测所述函数之间的调用关系信息中是否包括未被访问的函数;Detecting whether the calling relationship information between the functions includes unvisited functions;
如果所述函数之间的调用关系信息中包括未被访问的函数,则将所述未被访问的函数中的程序语句作为所述目标程序语句;If the calling relationship information between the functions includes an unvisited function, use the program statement in the unvisited function as the target program statement;
如果所述函数之间的调用关系信息中不包括未被访问的函数,则检测所述函数之间的调用关系信息中是否包括未被访问的目标程序语句。If the invocation relationship information between the functions does not include unvisited functions, it is detected whether the invocation relation information between the functions includes an unvisited target program statement.
本说明书实施例中,还包括:In the embodiment of this specification, it also includes:
将所述待检测的程序代码转换为预定表达形式的程序代码;Converting the program code to be detected into program code in a predetermined expression form;
所述获取待检测的程序代码中包含的函数,以及所述函数之间的调用关系信息,包括:The acquisition of the functions contained in the program code to be detected, and the calling relationship information between the functions, include:
获取转换为预定表达形式的程序代码中包含的函数,以及所述函数之间的调用关系信息。The functions contained in the program code converted into a predetermined expression form and the calling relationship information between the functions are acquired.
本说明书实施例中,还包括:In the embodiment of this specification, it also includes:
对转换后的程序代码中包含的函数的程序语句的结构进行识别,得到识别结果;Identify the structure of the program statement of the function contained in the converted program code, and obtain the identification result;
如果所述识别结果指示所述函数的程序语句为循环语句,则获取所述函数的程序语句对应的循环归纳变量和循环体;If the identification result indicates that the program statement of the function is a loop statement, acquiring the loop induction variable and the loop body corresponding to the program statement of the function;
确定所述循环归纳变量在所述循环体内的值范围。A range of values for the loop induction variable within the loop body is determined.
本说明书实施例中,还包括:In the embodiment of this specification, it also includes:
如果所述识别结果指示所述函数的程序语句为IF分支语句,则获取所述函数的程序语句对应的THEN语句块、ELSE语句块和条件判断变量;If the identification result indicates that the program statement of the function is an IF branch statement, then obtain the THEN statement block, the ELSE statement block and the condition judgment variable corresponding to the program statement of the function;
分别确定所述条件判断变量在所述THEN语句块内的值范围和在所述ELSE语句块内的值范围。The value range of the condition judgment variable in the THEN statement block and the value range in the ELSE statement block are respectively determined.
本说明书实施例中,还包括:In the embodiment of this specification, it also includes:
如果所述识别结果指示所述函数的程序语句为SWITCH选择语句,则获取所述函数的程序语句对应的CASE语句值及其对应的CASE语句块、DEFAULT语句块和选择变量;If the identification result indicates that the program statement of the function is a SWITCH selection statement, then obtain the CASE statement value corresponding to the program statement of the function and its corresponding CASE statement block, DEFAULT statement block and selection variable;
确定所述选择变量在每个CASE语句块内的值范围和在所述DEFAULT语句块内的值范围。Determine the value range of the selection variable within each CASE statement block and the value range within the DEFAULT statement block.
本说明书实施例中,所述获取所述函数之间的调用关系信息,包括:In the embodiment of this specification, the obtaining of the calling relationship information between the functions includes:
对所述函数之间的调用关系进行分析,得到函数调用图谱,所述函数调用图谱中包括多个函数和所述多个函数之间的连接线;Analyzing the calling relationship between the functions to obtain a function calling graph, where the function calling graph includes multiple functions and connecting lines between the multiple functions;
将所述函数调用图谱中的函数的形式参数与所述函数在所述函数调用图谱中的实际参数相连接,得到参数连接信息;Connect the formal parameters of the function in the function call map with the actual parameters of the function in the function call map to obtain parameter connection information;
获取预定的全局变量在所述函数调用图谱中各个函数之间的使用和定义关系,得到全局变量使用定义连接信息。The usage and definition relationship between each function in the function call graph of the predetermined global variable is acquired, and the connection information of the usage definition of the global variable is obtained.
本说明书实施例中,所述如果所述目标程序语句需要访问数组,则获取所述目标程序语句访问的数组的预定变量在所述数组对应的程序区域内的值范围,包括:In the embodiment of this specification, if the target program statement needs to access an array, the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array is obtained, including:
如果所述目标程序语句需要访问数组,则根据预定的使用定义关系信息,确定所述目标程序语句访问的数组的定义;If the target program statement needs to access the array, then according to the predetermined use definition relationship information, determine the definition of the array accessed by the target program statement;
根据预定的使用定义关系信息和所述目标程序语句访问的数组的定义对应的记录信息,查询所述目标程序语句访问的数组中每一维预定变量在所述数组对应的程序区域内的值范围。According to the predetermined usage definition relationship information and the record information corresponding to the definition of the array accessed by the target program statement, query the value range of each dimension of the predetermined variable in the array accessed by the target program statement in the program area corresponding to the array .
本说明书实施例提供一种数组越界访问的检测设备,通过获取待检测的程序代码中包含的函数,以及该函数之间的调用关系信息,如果该函数之间的调用关系信息中包括未被访问的目标程序语句,则检测目标程序语句是否需要访问数组,如果目标程序语句需要访问数组,则获取目标程序语句访问的数组的预定变量在该数组对应的程序区域内的值范围,基于目标程序语句访问的数组的预定变量在所述数组对应的程序区域内的值范围,对程序代码中是否包含数组越界访问进行检测,这样,通过对函数之间的调用关系信息中的程序语句的检测,来确定程序代码中是否包含数组越界访问,因此,可以使得该检测过程可以覆盖该程序代码的所有执行路径,提高了检测的准确性,此外,通过对函数之间的调用关系信息中的程序语句的检测和获取数组的预定变量在该数组对应的程序区域内的值范围,来进一步对程序代码中是否包含数组越界访问进行检测,可以使得数组越界访问的检测效率更高。An embodiment of the present specification provides a detection device for out-of-bounds access to an array. By acquiring the functions contained in the program code to be detected, and the calling relationship information between the functions, if the calling relationship information between the functions includes unaccessed If the target program statement needs to access the array, then obtain the value range of the predetermined variable of the array accessed by the target program statement in the program area corresponding to the array, based on the target program statement The value range of the predetermined variable of the accessed array in the program area corresponding to the array is detected, whether the program code contains array out-of-bounds access, so that by detecting the program statement in the calling relationship information between functions, It is determined whether the program code contains array out-of-bounds access. Therefore, the detection process can cover all execution paths of the program code, and the detection accuracy is improved. Detecting and obtaining the value range of the predetermined variable of the array in the program area corresponding to the array to further detect whether the program code includes out-of-bounds access to the array can make the detection of out-of-bounds access to the array more efficient.
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。The foregoing describes specific embodiments of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that in the embodiments and still achieve desirable results. Additionally, the processes depicted in the figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
在20世纪90年代,对于一个技术的改进可以很明显地区分是硬件上的改进(例如,对二极管、晶体管、开关等电路结构的改进)还是软件上的改进(对于方法流程的改进)。然而,随着技术的发展,当今的很多方法流程的改进已经可以视为硬件电路结构的直接改进。设计人员几乎都通过将改进的方法流程编程到硬件电路中来得到相应的硬件电路结构。因此,不能说一个方法流程的改进就不能用硬件实体模块来实现。例如,可编程逻辑器件(Programmable Logic Device,PLD)(例如现场可编程门阵列(Field Programmable GateArray,FPGA))就是这样一种集成电路,其逻辑功能由用户对器件编程来确定。由设计人员自行编程来把一个数字系统“集成”在一片PLD上,而不需要请芯片制造厂商来设计和制作专用的集成电路芯片。而且,如今,取代手工地制作集成电路芯片,这种编程也多半改用“逻辑编译器(logic compiler)”软件来实现,它与程序开发撰写时所用的软件编译器相类似,而要编译之前的原始代码也得用特定的编程语言来撰写,此称之为硬件描述语言(Hardware Description Language,HDL),而HDL也并非仅有一种,而是有许多种,如ABEL(Advanced Boolean Expression Language)、AHDL(Altera Hardware DescriptionLanguage)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(RubyHardware Description Language)等,目前最普遍使用的是VHDL(Very-High-SpeedIntegrated Circuit Hardware Description Language)与Verilog。本领域技术人员也应该清楚,只需要将方法流程用上述几种硬件描述语言稍作逻辑编程并编程到集成电路中,就可以很容易得到实现该逻辑方法流程的硬件电路。In the 1990s, improvements in a technology could be clearly differentiated between improvements in hardware (eg, improvements to circuit structures such as diodes, transistors, switches, etc.) or improvements in software (improvements in method flow). However, with the development of technology, the improvement of many methods and processes today can be regarded as a direct improvement of the hardware circuit structure. Designers almost get the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be realized by hardware entity modules. For example, a Programmable Logic Device (PLD) (eg, Field Programmable Gate Array (FPGA)) is an integrated circuit whose logic function is determined by user programming of the device. It is programmed by the designer to "integrate" a digital system on a PLD without having to ask the chip manufacturer to design and manufacture a dedicated integrated circuit chip. And, instead of making integrated circuit chips by hand, these days, much of this programming is done using software called a "logic compiler", which is similar to the software compiler used in program development and writing, but before compiling The original code also has to be written in a specific programming language, which is called Hardware Description Language (HDL), and there is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language) , AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (RubyHardware Description Language), etc. The most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. It should also be clear to those skilled in the art that a hardware circuit for implementing the logic method process can be easily obtained by simply programming the method process in the above-mentioned several hardware description languages and programming it into the integrated circuit.
控制器可以按任何适当的方式实现,例如,控制器可以采取例如微处理器或处理器以及存储可由该(微)处理器执行的计算机可读程序代码(例如软件或固件)的计算机可读介质、逻辑门、开关、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程逻辑控制器和嵌入微控制器的形式,控制器的例子包括但不限于以下微控制器:ARC 625D、Atmel AT91SAM、Microchip PIC18F26K20以及Silicone Labs C8051F320,存储器控制器还可以被实现为存储器的控制逻辑的一部分。本领域技术人员也知道,除了以纯计算机可读程序代码方式实现控制器以外,完全可以通过将方法步骤进行逻辑编程来使得控制器以逻辑门、开关、专用集成电路、可编程逻辑控制器和嵌入微控制器等的形式来实现相同功能。因此这种控制器可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置也可以视为硬件部件内的结构。或者甚至,可以将用于实现各种功能的装置视为既可以是实现方法的软件模块又可以是硬件部件内的结构。The controller may be implemented in any suitable manner, for example, the controller may take the form of eg a microprocessor or processor and a computer readable medium storing computer readable program code (eg software or firmware) executable by the (micro)processor , logic gates, switches, application specific integrated circuits (ASICs), programmable logic controllers and embedded microcontrollers, examples of controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicon Labs C8051F320, the memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that, in addition to implementing the controller in the form of pure computer-readable program code, the controller can be implemented as logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded devices by logically programming the method steps. The same function can be realized in the form of a microcontroller, etc. Therefore, such a controller can be regarded as a hardware component, and the devices included therein for realizing various functions can also be regarded as a structure within the hardware component. Or even, the means for implementing various functions can be regarded as both a software module implementing a method and a structure within a hardware component.
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机。具体的,计算机例如可以为个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。The systems, devices, modules or units described in the above embodiments may be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or A combination of any of these devices.
为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本说明书一个或多个实施例时可以把各单元的功能在同一个或多个软件和/或硬件中实现。For the convenience of description, when describing the above device, the functions are divided into various units and described respectively. Of course, when implementing one or more embodiments of the present specification, the functions of each unit may be implemented in one or more software and/or hardware.
本领域内的技术人员应明白,本说明书的实施例可提供为方法、系统、或计算机程序产品。因此,本说明书一个或多个实施例可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本说明书一个或多个实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。As will be appreciated by one skilled in the art, the embodiments of the present specification may be provided as a method, system, or computer program product. Accordingly, one or more embodiments of this specification may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, one or more embodiments of the present specification may employ a computer program implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein form of the product.
本说明书的实施例是参照根据本说明书实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数组越界访问的检测设备的处理器以产生一个机器,使得通过计算机或其他可编程数组越界访问的检测设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。Embodiments of the specification are described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the specification. It will be understood that each flow and/or block in the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded processor or other programmable array out-of-bounds access detection device to produce a machine that enables processing by a computer or other programmable array out-of-bounds access detection device The instructions executed by the processor produce means for implementing the functions specified in the flow or blocks of the flowchart and/or the block or blocks of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数组越界访问的检测设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable array out-of-bounds access detection device to function in a particular manner, such that the instructions stored in the computer readable memory result in an article of manufacture comprising the instruction means , the instruction means implements the functions specified in the flow or flow of the flowchart and/or the block or blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数组越界访问的检测设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable array out-of-bounds access detection device, such that a series of operational steps are performed on the computer or other programmable device to produce a computer-implemented process, which is then executed on the computer or other programmable device The instructions executed on the above provide steps for implementing the functions specified in the flowchart or blocks and/or the block or blocks of the block diagrams.
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。Memory may include non-persistent memory in computer readable media, random access memory (RAM) and/or non-volatile memory in the form of, for example, read only memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media includes both persistent and non-permanent, removable and non-removable media, and storage of information may be implemented by any method or technology. Information may be computer readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), Flash Memory or other memory technology, Compact Disc Read Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, Magnetic tape cartridges, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, excludes transitory computer-readable media, such as modulated data signals and carrier waves.
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。It should also be noted that the terms "comprising", "comprising" or any other variation thereof are intended to encompass a non-exclusive inclusion such that a process, method, article or device comprising a series of elements includes not only those elements, but also Other elements not expressly listed, or which are inherent to such a process, method, article of manufacture, or apparatus are also included. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in the process, method, article of manufacture, or device that includes the element.
本领域技术人员应明白,本说明书的实施例可提供为方法、系统或计算机程序产品。因此,本说明书一个或多个实施例可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本说明书一个或多个实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。As will be appreciated by one skilled in the art, the embodiments of the present specification may be provided as a method, a system or a computer program product. Accordingly, one or more embodiments of this specification may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, one or more embodiments of the present specification may employ a computer program implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein form of the product.
本说明书一个或多个实施例可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本说明书一个或多个实施例,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。One or more embodiments of this specification may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. One or more embodiments of this specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including storage devices.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。Each embodiment in this specification is described in a progressive manner, and the same and similar parts between the various embodiments may be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, as for the system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and for related parts, please refer to the partial descriptions of the method embodiments.
以上所述仅为本说明书的实施例而已,并不用于限制本说明书。对于本领域技术人员来说,本说明书可以有各种更改和变化。凡在本说明书的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本说明书的权利要求范围之内。The above descriptions are merely examples of the present specification, and are not intended to limit the present specification. Various modifications and variations of this specification are possible for those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this specification shall be included within the scope of the claims of this specification.
Claims (17)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910828384.9A CN110674495B (en) | 2019-09-03 | 2019-09-03 | Detection method, device and equipment for group border crossing access |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910828384.9A CN110674495B (en) | 2019-09-03 | 2019-09-03 | Detection method, device and equipment for group border crossing access |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110674495A true CN110674495A (en) | 2020-01-10 |
CN110674495B CN110674495B (en) | 2021-07-09 |
Family
ID=69076243
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910828384.9A Active CN110674495B (en) | 2019-09-03 | 2019-09-03 | Detection method, device and equipment for group border crossing access |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110674495B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113849395A (en) * | 2021-08-10 | 2021-12-28 | 浙江中控技术股份有限公司 | Configuration method, dynamic detection method of array subscript out of bounds, decentralized control system |
Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080127301A1 (en) * | 2006-08-28 | 2008-05-29 | Microsoft Corporation | Delivering Callbacks Into Secure Application Areas |
CN101482847A (en) * | 2009-01-19 | 2009-07-15 | 北京邮电大学 | Detection method based on safety bug defect mode |
CN101894064A (en) * | 2009-05-21 | 2010-11-24 | 北京邮电大学 | A Software Testing Method Using Cross-Functional Analysis |
CN101937388A (en) * | 2009-12-17 | 2011-01-05 | 北京测腾信息技术有限公司 | High-extensibility and high-maintainability source code defect detection method and device |
US20110154122A1 (en) * | 2009-12-18 | 2011-06-23 | Sun Microsystems, Inc. | System and method for overflow detection using symbolic analysis |
CN103778061A (en) * | 2014-01-17 | 2014-05-07 | 南京航空航天大学 | Automatic detection and correction method for array out-of-bound errors |
US20140173734A1 (en) * | 2006-10-30 | 2014-06-19 | Angelos D. Keromytis | Methods, media, and systems for detecting an anomalous sequence of function calls |
CN104573503A (en) * | 2015-02-11 | 2015-04-29 | 中国农业银行股份有限公司 | Method and device for detecting memory access overflow |
CN105912459A (en) * | 2016-04-01 | 2016-08-31 | 北京理工大学 | Detection method for array bound based on symbolic execution |
CN106940654A (en) * | 2017-02-15 | 2017-07-11 | 南京航空航天大学 | The automatic detection and localization method of EMS memory error in source code |
US20170322784A1 (en) * | 2001-07-10 | 2017-11-09 | Micron Technology, Inc. | Dynamic arrays and overlays with bounds policies |
CN107908405A (en) * | 2017-11-17 | 2018-04-13 | 苏州蜗牛数字科技股份有限公司 | The static examination & verification device and method of code |
-
2019
- 2019-09-03 CN CN201910828384.9A patent/CN110674495B/en active Active
Patent Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20170322784A1 (en) * | 2001-07-10 | 2017-11-09 | Micron Technology, Inc. | Dynamic arrays and overlays with bounds policies |
US20080127301A1 (en) * | 2006-08-28 | 2008-05-29 | Microsoft Corporation | Delivering Callbacks Into Secure Application Areas |
US20140173734A1 (en) * | 2006-10-30 | 2014-06-19 | Angelos D. Keromytis | Methods, media, and systems for detecting an anomalous sequence of function calls |
CN101482847A (en) * | 2009-01-19 | 2009-07-15 | 北京邮电大学 | Detection method based on safety bug defect mode |
CN101894064A (en) * | 2009-05-21 | 2010-11-24 | 北京邮电大学 | A Software Testing Method Using Cross-Functional Analysis |
CN101937388A (en) * | 2009-12-17 | 2011-01-05 | 北京测腾信息技术有限公司 | High-extensibility and high-maintainability source code defect detection method and device |
US20110154122A1 (en) * | 2009-12-18 | 2011-06-23 | Sun Microsystems, Inc. | System and method for overflow detection using symbolic analysis |
CN103778061A (en) * | 2014-01-17 | 2014-05-07 | 南京航空航天大学 | Automatic detection and correction method for array out-of-bound errors |
CN104573503A (en) * | 2015-02-11 | 2015-04-29 | 中国农业银行股份有限公司 | Method and device for detecting memory access overflow |
CN105912459A (en) * | 2016-04-01 | 2016-08-31 | 北京理工大学 | Detection method for array bound based on symbolic execution |
CN106940654A (en) * | 2017-02-15 | 2017-07-11 | 南京航空航天大学 | The automatic detection and localization method of EMS memory error in source code |
CN107908405A (en) * | 2017-11-17 | 2018-04-13 | 苏州蜗牛数字科技股份有限公司 | The static examination & verification device and method of code |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113849395A (en) * | 2021-08-10 | 2021-12-28 | 浙江中控技术股份有限公司 | Configuration method, dynamic detection method of array subscript out of bounds, decentralized control system |
Also Published As
Publication number | Publication date |
---|---|
CN110674495B (en) | 2021-07-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109189682B (en) | Script recording method and device | |
KR101840905B1 (en) | Counter operation in a state machine lattice | |
TWI736123B (en) | BLE communication method, device, equipment and storage medium | |
CN107229559B (en) | Detection method and device for testing integrity of service system | |
JP2018536351A (en) | Method and apparatus for identifying network attacks | |
CN111860011A (en) | A kind of target graphic code identification method and device | |
WO2020237508A1 (en) | Assertion validation code binding method and apparatus | |
CN114547024A (en) | A SQL statement risk detection method, device, equipment and medium | |
CN111368163A (en) | A method, system and device for identifying crawler data | |
CN109271453B (en) | Method and device for determining database capacity | |
CN110542474A (en) | Device vibration signal detection method, system, medium and device | |
CN116822606A (en) | Training method, device, equipment and storage medium of anomaly detection model | |
CN111753328B (en) | Private data leakage risk detection method and system | |
WO2023217118A1 (en) | Code test method and apparatus, and test case generation method and apparatus | |
CN112491816A (en) | Service data processing method and device | |
TWI705378B (en) | Vector processing method, device and equipment for RPC information | |
CN110245136B (en) | Data retrieval method, device, equipment and storage equipment | |
CN110674495A (en) | Detection method, device and equipment for group border crossing access | |
WO2024212719A1 (en) | Prediction method and apparatus, readable storage medium and electronic device | |
CN112181808A (en) | A program concurrency defect detection method, apparatus, device and storage medium | |
US11461220B2 (en) | Techniques to identify improper information in call stacks | |
CN108133123B (en) | Application program identification method and system | |
CN114238119B (en) | Automated testing method and system for Android applications and storage medium | |
CN108062338B (en) | A method and apparatus for evaluating the navigation ability of functional pages | |
CN114167222B (en) | Smart power grid fault real-time monitoring and positioning method and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right |
Effective date of registration: 20230427 Address after: 51 Brasbala Road, Singapore, No. 04-08 Lazada 1 Patentee after: Alipay Intellectual Property Holding Co. Address before: 14/F, Zhonggang Building, 8 Hennessy Road, Wanchai Patentee before: XC5 Hong Kong Ltd. |
|
TR01 | Transfer of patent right |