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

max_len() 展示的可用长度在写 environ 区域后不准确 #5

Open
unknowndevQwQ opened this issue Feb 14, 2025 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@unknowndevQwQ
Copy link
Owner

unknowndevQwQ commented Feb 14, 2025

Describe the bug
目前已知可以通过更改 argv 字符串来达到更改目的的 os kernel 有 linux, darwin, solaris/illumos, openbsd(尚未测试),且都保证 argv 和 environ 连续,且可以在 argv 长度不足的情况下继续写入 environ 的内存来展示更多 cmdline 字符串
但问题是,如果 argv + environ 长度大于 4096 且确实写了这么多,os 的行为是什么呢?
omnios 在写了 4096 个以上的字符串时,只会展示 4095 个(排除 null),Linux 则是 4096 个,目前尚未测试 macos ,但当前 max_len() 方法只是简单地把 argv 和 environ 长度相加而没考虑 kernel 行为

To Reproduce
Steps to reproduce the behavior:

  1. new()
  2. set("a".repeat(6144).as_bytes())
  3. See error

Expected behavior
根据 os 行为限制 max_len() 长度

Additional context
可能要考虑 argv 长度大于 4096 时不触碰 environ,如此长的 argv 对于大部分更改 cmdline 的需求绰绰有余,同时写入 environ 会导致 Linux 把 cmdline 固定为不允许插入 null 的 4096 字节,导致这种情况下写入 environ 没有意义

@unknowndevQwQ unknowndevQwQ added the bug Something isn't working label Feb 14, 2025
@unknowndevQwQ unknowndevQwQ self-assigned this Feb 14, 2025
unknowndevQwQ added a commit that referenced this issue Feb 15, 2025
Prepare to resolve issue #5
see: #5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant