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

直接将 getenv() 的结果传入 strcpy() 可能导致内存写越界 #7

Closed
GoogleCodeExporter opened this issue Aug 31, 2015 · 5 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
参考:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=430420

What is the expected output? What do you see instead?
程序不应该崩溃。程序出现段错误,并崩溃。

What version of the product are you using? On what operating system?
影响到所有版本。

Please provide any additional information below.
是否可以考虑用 snprintf() 来代替 strcpy(), strcat(),...?

Original issue reported on code.google.com by tchai...@gmail.com on 13 May 2008 at 1:29

@GoogleCodeExporter
Copy link
Author

之前mail list里面也有人指出了这个问题。

一般情况下,getenv ("HOME")的长度远小于PATH_MAX(文件extra.c 
函数LoadExtraIM 使用的是256),
不过确实对恶意输入没有抵抗力。

现在的tool.c中已经改用snprintf(),而且也检查了getenv 
("HOME")的有效性。

Original comment by tiangui2...@gmail.com on 14 May 2008 at 1:22

@GoogleCodeExporter
Copy link
Author

tiangui,谢谢你的解释。
但是 table.c, py.c 和其它几个 .c 文件也有这个问题。我把 py.c 
中的部分有问题的
strcpy() 改掉了,patch 见附件。你能帮我把它加入 SVN 
中的代码么?

谢谢。

Original comment by tchai...@gmail.com on 14 May 2008 at 1:41

Attachments:

@GoogleCodeExporter
Copy link
Author

原先的讨论帖子,做个记录:
http://groups.google.com/group/fcitx-dev/browse_thread/thread/300f9b89c78bd7d9?h
l=zh-CN

Original comment by tiangui2...@gmail.com on 17 May 2008 at 4:44

@GoogleCodeExporter
Copy link
Author

路径已经全部交给 src/fcitx-config/xdg.c 处理

应该是都解决了。

Original comment by wen...@gmail.com on 26 Oct 2010 at 8:05

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

Issue 160 has been merged into this issue.

Original comment by wen...@gmail.com on 26 Oct 2010 at 8:32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant