2
0
Mike Pall 5 жил өмнө
parent
commit
2e68e1fc18
2 өөрчлөгдсөн 17 нэмэгдсэн , 0 устгасан
  1. 7 0
      src/lib_jit.c
  2. 10 0
      src/lj_arch.h

+ 7 - 0
src/lib_jit.c

@@ -113,6 +113,13 @@ LJLIB_CF(jit_status)
 #endif
 }
 
+LJLIB_CF(jit_security)
+{
+  int idx = lj_lib_checkopt(L, 1, -1, LJ_SECURITY_MODESTRING);
+  setintV(L->top++, ((LJ_SECURITY_MODE >> (2*idx)) & 3));
+  return 1;
+}
+
 LJLIB_CF(jit_attach)
 {
 #ifdef LUAJIT_DISABLE_VMEVENT

+ 10 - 0
src/lj_arch.h

@@ -665,4 +665,14 @@ extern void *LJ_WIN_LOADLIBA(const char *path);
 #define LUAJIT_SECURITY_MCODE	1
 #endif
 
+#define LJ_SECURITY_MODE \
+  ( 0u \
+  | ((LUAJIT_SECURITY_PRNG & 3) << 0) \
+  | ((LUAJIT_SECURITY_STRHASH & 3) << 2) \
+  | ((LUAJIT_SECURITY_STRID & 3) << 4) \
+  | ((LUAJIT_SECURITY_MCODE & 3) << 6) \
+  )
+#define LJ_SECURITY_MODESTRING \
+  "\004prng\007strhash\005strid\005mcode"
+
 #endif