Skip to content

cocos lua app will crash if lua include paths order is incorrect!!! #20273

@sonyps5201314

Description

@sonyps5201314
  • cocos2d-x version: 3.17.2 git latest
  • devices test on:windows 8.1
  • developing environments
    • VS version:vs 2017 latest

Steps to Reproduce:

  1. create vs client game project,include path is $(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\luajit\include
  2. call lua_getstack(L, depth, &entry); next the program will crash with memory error.
    fix solution:fix #define LUA_IDSIZE 512 in frameworks\cocos2d-x\external\lua\lua\luaconf.h as same to frameworks\cocos2d-x\external\lua\luajit\include\luaconf.h

我再用中文说一遍嘛,怕你们不懂,如果用户创建的游戏工程包含路径中$(EngineRoot)external\lua\lua在$(EngineRoot)external\lua\luajit\include前面因为都有luaconf.h这个文件,所以VS的编译器会使用第一个目录下的luaconf.h即frameworks\cocos2d-x\external\lua\lua\luaconf.h,但是这个目录下的LUA_IDSIZE宏的定义和luajit下的是不同的,cocos的patch文件只修改了luajit中的这个宏值为512,所以一旦调用lua_Debug结构体相关的函数如lua_getstack,lua_getinfo等,luajit内部就会写入512个字节到lua_Debug的short_src字段,而这里被定义成了60个大小和luajit内部中的不一致,所以导致了写多了字节进去,进而导致其他变量的缓冲区被覆盖了,进而可能引起崩溃,甚至远程代码执行漏洞。所以请两个地方都同步修改成512就没事了,或者修改回原来的60,即去掉cocos的这个patch。

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions