CWE-572 调用线程的run()方法而非start()方法

admin 2021年11月21日19:07:56CWE(弱点枚举)评论44 views1079字阅读3分35秒阅读模式

CWE-572 调用线程的run()方法而非start()方法

Call to Thread run() instead of start()

结构: Simple

Abstraction: Variant

状态: Draft

被利用可能性: unkown

基本描述

The program calls a thread's run() method instead of calling start(), which causes the code to run in the thread of the caller instead of the callee.

扩展描述

In most cases a direct call to a Thread object's run() method is a bug. The programmer intended to begin a new thread of control, but accidentally called run() instead of start(), so the run() method will execute in the caller's thread of control.

相关缺陷

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

  • cwe_Nature: ChildOf cwe_CWE_ID: 821 cwe_View_ID: 699 cwe_Ordinal: Primary

适用平台

Language: {'cwe_Name': 'Java', 'cwe_Prevalence': 'Undetermined'}

常见的影响

范围 影响 注释
Other ['Quality Degradation', 'Varies by Context']

可能的缓解方案

Implementation

策略:

Use the start() method instead of the run() method.

示例代码

The following excerpt from a Java program mistakenly calls run() instead of start().

bad Java

Thread thr = new Thread() {

public void run() {

...

}

};

thr.run();

分类映射

映射的分类名 ImNode ID Fit Mapped Node Name
The CERT Oracle Secure Coding Standard for Java (2011) THI00-J Do not invoke Thread.run()
Software Fault Patterns SFP3 Use of an improper API

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

特别标注: 本站(CN-SEC.COM)所有文章仅供技术研究,若将其信息做其他用途,由用户承担全部法律及连带责任,本站不承担任何法律及连带责任,请遵守中华人民共和国安全法.
  • 我的微信
  • 微信扫一扫
  • weinxin
  • 我的微信公众号
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年11月21日19:07:56
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                  CWE-572 调用线程的run()方法而非start()方法 http://cn-sec.com/archives/613467.html

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: