Unlock instant, AI-driven research and patent intelligence for your innovation.

Defensive programming method based on function access global variables

A technology of global variables and programming methods, applied in program control design, electrical digital data processing, instruments, etc., can solve problems such as ignoring the safety of global variables

Active Publication Date: 2010-08-18
NANJING NRIET IND CORP
View PDF4 Cites 8 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0003] The purpose of the present invention is to design a defensive programming method based on function access to global variables for existing defensive programming methods that mostly ignore the security issues caused by global variables

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0012] The present invention will be further described below in conjunction with embodiment.

[0013] A defensive programming method based on function access to global variables, combined with existing defensive programming methods to provide a more comprehensive defense of the software, it can also use the defensive programming method of functions to defend global variables, the specific steps include hiding The global variable name, the encapsulating global variable access function interface and the defense function of the global variable access function are respectively implemented as follows:

[0014] (1). Hide the name of the global variable; the declaration of the protected global variable does not appear in the referenced header file, and the definition file is provided as a binary file or the programming specification file stipulates that names other than the header file declaration cannot be used. The hiding of global variable names is done.

[0015] (2). Encapsulate...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention relates to a defensive programming method based on function access global variables, which is characterized by comprising the following steps of: (1) hiding global variable names: enabling the protected declaration of global variables to not appear in a quoted header file, and providing a defined file as a binary file or prescribing that names which are not contained in the declaration of the header file can not be used through programming specification files, thereby realizing the purpose of hiding the global variable names; (2) declaring an access function of the global variables and a data structure of the global variables: declaring the data structure of the global variables and the access function of the global variables in the header file, adding a mutex lock in the data structure of the global variables, and respectively declaring an acquiring function and a modifying function; and (3) defining the access function of the global variables: selecting asserted defense or other existing function defense methods, programming code defense, context access defense and mutex defense in the definition phase of the access function of the global variables. The invention can prevent wrong global variables from being accessed in the programming process, realize global variable access of different rights, and automatically judge the context to shield the access of the task which has no right to access the global variables.

Description

technical field [0001] The invention relates to a computer program security method, in particular to a security defense method used in software with defensive programming requirements, in particular to a defensive programming method based on function access to global variables. Background technique [0002] We all know that defensive programming is a careful and careful programming method. In order to develop reliable software, each component in the system needs to be designed so that it "protects" itself as much as possible. Defend against assumption errors by explicitly checking for them in the code. This effort prevents (or at least detects) code being invoked in a potentially erroneous manner with undefined results. Defensive programming catches smaller problems early on, rather than waiting until they grow into catastrophes. Of course, defensive programming does not eliminate all programming errors. But questions will be less annoying and easier to modify. Defensiv...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
Patent Type & Authority Applications(China)
IPC IPC(8): G06F9/45
Inventor 束元蔡李峰朱骞
Owner NANJING NRIET IND CORP