Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] double free issue #9397

Closed
SoftSec-Tech opened this issue Sep 5, 2024 · 3 comments
Closed

[Bug] double free issue #9397

SoftSec-Tech opened this issue Sep 5, 2024 · 3 comments
Labels
good first issue Good for newcomers 新手任务

Comments

@SoftSec-Tech
Copy link

RT-Thread Version

1cc0fb8

Hardware Type/Architectures

stm32

Develop Toolchain

GCC

Describe the bug

  1. There is double free issue in line 770 of https://github.com/RT-Thread/rt-thread/blob/master/components/finsh/msh.c.
  2. This issue was detected by Static Analysis tool - StatiCode,
    rt-thready-defect2
    As in the screenshot, in step 38, call closedir(dir) and free the memory; And then in step 39, call closeddir(dir) and free memory again., which caused double free issue.

Other additional context

No response

@supperthomas supperthomas added the good first issue Good for newcomers 新手任务 label Sep 6, 2024
@ChinoUkaegbu
Copy link

Hi I'd like to work on this but I don't think there's a double free issue. It seems like the closedir(dir) on line 770 is freeing the variable defined in line 631 while the closedir(dir) on line 761 is freeing the variable defined in line 759. If that's the case then I believe one of the variables may need to be renamed.

@BernardXiong
Copy link
Member

Hi I'd like to work on this but I don't think there's a double free issue. It seems like the closedir(dir) on line 770 is freeing the variable defined in line 631 while the closedir(dir) on line 761 is freeing the variable defined in line 759. If that's the case then I believe one of the variables may need to be renamed.

Yes, you are right.

@CYFS3 CYFS3 mentioned this issue Sep 24, 2024
9 tasks
mysterywolf pushed a commit that referenced this issue Sep 25, 2024
为什么提交这份PR (why to submit this PR)
#9397

你的解决方案是什么 (what is your solution)
将 line 758的dir改为link_dir
@mysterywolf
Copy link
Member

fixed in #9464

rcitach pushed a commit to rcitach/rt-thread that referenced this issue Nov 1, 2024
为什么提交这份PR (why to submit this PR)
RT-Thread#9397

你的解决方案是什么 (what is your solution)
将 line 758的dir改为link_dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers 新手任务
Projects
None yet
Development

No branches or pull requests

5 participants