C: sprintf 通过 strlen 通向 SIGSEGV 核心
我的 C 应用程序有以下两行:
char buf[1024];
sprintf(buf, "%s/game/rabbit/habit/cmd/talkPipe", getenv("APPLICATION_PATH"));
应用程序偶尔会以以下方式因 SIGSEGV 崩溃:
strlen(ff2ba231, 0, ffbfe1d0, 10, 7fff24d7, 0)+0x50
sprintf(ffbfe2a4, ff2ba231, 0, 74656400, 12, ff362ef2)+0x24
RabbitTalk(ffbfea80, ffbfee50, 1, d, ffbfea12, 0)+0x21c
...
任何人都可以传递有关可能出现问题的位置/内容的提示吗?
非常感谢,
My C application has the following two lines:
char buf[1024];
sprintf(buf, "%s/game/rabbit/habit/cmd/talkPipe", getenv("APPLICATION_PATH"));
The application sporadically crashes with SIGSEGV in the following manner:
strlen(ff2ba231, 0, ffbfe1d0, 10, 7fff24d7, 0)+0x50
sprintf(ffbfe2a4, ff2ba231, 0, 74656400, 12, ff362ef2)+0x24
RabbitTalk(ffbfea80, ffbfee50, 1, d, ffbfea12, 0)+0x21c
...
Can anyone pass a hint on where/what might be the problem?
Thanx a lot,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许是因为 getenv 返回 NULL ?
即使这不是当前的问题,您也应该检查 NULL :大多数旧式 C 函数都不会。
Maybe because getenv returns NULL ?
Even if it's not the problem at hand you should check for NULL : most old style C functions don't.
如果环境变量不存在(未导出),
getenv()
将返回NULL
,这会导致SIGSEGV
getenv()
would returnNULL
if the environment variable not exist (not exported), this cause theSIGSEGV