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

Fix metatable security. #309

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Source/LuaBridge/detail/Namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class Namespace : public detail::Registrar

if (Security::hideMetatables())
{
lua_pushnil(L);
lua_pushboolean(L, 0);
rawsetfield(L, -2, "__metatable");
}
}
Expand Down Expand Up @@ -221,7 +221,7 @@ class Namespace : public detail::Registrar

if (Security::hideMetatables())
{
lua_pushnil(L);
lua_pushboolean(L, 0);
rawsetfield(L, -2, "__metatable");
}
}
Expand Down Expand Up @@ -1041,6 +1041,12 @@ class Namespace : public detail::Registrar
lua_newtable(L); // Stack: pns, ns, propset table (ps)
lua_rawsetp(L, -2, detail::getPropsetKey()); // ns [propsetKey] = ps. Stack: pns, ns

if (Security::hideMetatables())
{
lua_pushboolean(L, 0);
rawsetfield(L, -2, "__metatable");
}

Comment on lines +1044 to +1049
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces should be used instead of tabs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it okay for you when you just push the change under your name?

// pns [name] = ns
lua_pushvalue(L, -1); // Stack: pns, ns, ns
rawsetfield(L, -3, name); // Stack: pns, ns
Expand Down