Skip to content

Commit 2c45563

Browse files
att
1 parent 8d1ad49 commit 2c45563

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ if you want to embed lua in single compilation, create a **test.c** file:
99
#define LUA_SINGLE_UNITY_EMBED_MODE
1010
#define LUA_SINGLE_UNITY_GUESS_OS
1111
#include "lua_single_unity_classic_onelua.c"
12-
1312
int main() {
1413

1514
lua_State *L = luaL_newstate();
16-
const char *expr = "return 1 + 2 * 3";
15+
luaL_openlibs(L);
16+
const char *expr = "return os.execute('echo carefull these could be executed by your user ')";
1717
if (luaL_dostring(L, expr) == LUA_OK) {
1818
if (lua_isnumber(L, -1)) {
1919
double result = lua_tonumber(L, -1);
@@ -25,6 +25,7 @@ int main() {
2525
lua_close(L);
2626
return 0;
2727
}
28+
2829
```
2930

3031
## Embeding lua in Multi Compilation
@@ -56,9 +57,16 @@ and compile with:
5657
cc test.c lua_single_unity_classic_onelua.o -lm
5758
```
5859

60+
## Loading Native libs
61+
native libs are contained into the amalgamation, so you can just call the **luaL_openlibs(L);**
62+
function to load the native libs.
63+
Note that, these its a dangerous function, since if you are inside a a low code, it can allow
64+
users to run any code, so be careful with this function.
65+
```
66+
5967
60-
# Compiling the runtime
6168
69+
## Compiling the runtime
6270
if you want to compile the **lua_runtime**, you can compile with:
6371
6472
```bash
@@ -84,7 +92,7 @@ and running the bytecode in the lua virtual machine with
8492

8593

8694

87-
# Build From Scracth
95+
## Build From Scracth
8896

8997
if you want to build from scratch, you will need to have the follwoing tools
9098
installed

test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#define LUA_SINGLE_UNITY_EMBED_MODE
22
#define LUA_SINGLE_UNITY_GUESS_OS
33
#include "lua_single_unity_classic_onelua.c"
4-
54
int main() {
65

76
lua_State *L = luaL_newstate();
8-
const char *expr = "return 1 + 2 * 3";
7+
luaL_openlibs(L);
8+
const char *expr = "return os.execute('echo carefull these could be executed by your user ')";
99
if (luaL_dostring(L, expr) == LUA_OK) {
1010
if (lua_isnumber(L, -1)) {
1111
double result = lua_tonumber(L, -1);

0 commit comments

Comments
 (0)