RT-Thread / RT-Thread/rt-thread

[Bug] ymodem中ry_sy.c文件中函数_rym_recv_begin进行传输文件名称拷贝赋值时,存在内存泄露,导致最后释放内存的时候进入断言错误

Open
#10,370 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
12.2k
Forks
5.4k
Avg merge
4d 12h
Merged PRs (30d)
40

Description

RT-Thread Version

5.10

Hardware Type/Architectures

GD32F470ZG

Develop Toolchain

GCC

Describe the bug

1.文件路径名称大小拷贝是根据ymodem协议数据包大小进行拷贝,但是保存文件名称buffer大小是根据dfs中文件路径名称长度的宏定义,如果文件路径名称的宏定义大小小于ymodem协议数据包大小就会导致内存泄露。
2.将函数中rt_strncpy(ret+1,(const char*)buf, len-1)修改为rt_strncpy(ret+1,(const char*)buf, sizeof(cctx->fpath)-1)就不会存在问题

Other additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect the ymodem/ry_sy.c file and the _rym_recv_begin function, focusing on the rt_strncpy call that copies the received filename into cctx->fpath. Check the buffer-size boundary against the YMODEM packet length and confirm that a transfer followed by cleanup no longer triggers the memory-release assertion.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.