CWE-253 对函数返回值的检查不正确

admin 2022年1月5日21:04:43评论53 views字数 1237阅读4分7秒阅读模式

CWE-253 对函数返回值的检查不正确

Incorrect Check of Function Return Value

结构: Simple

Abstraction: Base

状态: Incomplete

被利用可能性: Low

基本描述

The software incorrectly checks a return value from a function, which prevents the software from detecting errors or exceptional conditions.

扩展描述

Important and common functions will return some value about the success of its actions. This will alert the program whether or not to handle any errors caused by that function.

相关缺陷

  • cwe_Nature: ChildOf cwe_CWE_ID: 573 cwe_View_ID: 1000 cwe_Ordinal: Primary

  • cwe_Nature: ChildOf cwe_CWE_ID: 754 cwe_View_ID: 1000

适用平台

Language: {'cwe_Class': 'Language-Independent', 'cwe_Prevalence': 'Undetermined'}

常见的影响

范围 影响 注释
['Availability', 'Integrity'] ['Unexpected State', 'DoS: Crash, Exit, or Restart'] An unexpected return value could place the system in a state that could lead to a crash or other unintended behaviors.

可能的缓解方案

Architecture and Design

策略: Language Selection

Use a language or compiler that uses exceptions and requires the catching of those exceptions.

Implementation

策略:

Properly check all functions which return a value.

Implementation

策略:

When designing any function make sure you return a value or throw an exception in case of an error.

示例代码

This code attempts to allocate memory for 4 integers and checks if the allocation succeeds.

bad C

tmp = malloc(sizeof(int) * 4);
if (tmp

perror("Failure");
//should have checked if the call returned 0

}文章来源于互联网:scap中文网

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年1月5日21:04:43
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   CWE-253 对函数返回值的检查不正确https://cn-sec.com/archives/612810.html

发表评论

匿名网友 填写信息