Fix Lua panic in redbean when calling request/connection functions from .init.lua

The error calls were triggered appropriately, but used the global Lua
state instead of the current Lua state (within protected call), which
triggered Lua panic. This executes the error in the proper context.
This commit is contained in:
Paul Kulchenko 2021-10-21 23:04:28 -07:00
parent 425a57080d
commit 3b75363e44

View file

@ -2992,7 +2992,7 @@ static const char *LuaCheckHost(lua_State *L, int idx, size_t *hostlen) {
return host; return host;
} }
static void OnlyCallFromInitLua(const char *api) { static void OnlyCallFromInitLua(lua_State *L, const char *api) {
if (isinitialized) { if (isinitialized) {
luaL_error(L, "%s() should be called from the global scope of .init.lua", luaL_error(L, "%s() should be called from the global scope of .init.lua",
api); api);
@ -3000,21 +3000,21 @@ static void OnlyCallFromInitLua(const char *api) {
} }
} }
static void DontCallFromInitLua(const char *api) { static void DontCallFromInitLua(lua_State *L, const char *api) {
if (!isinitialized) { if (!isinitialized) {
luaL_error(L, "%s() can't be called from .init.lua", api); luaL_error(L, "%s() can't be called from .init.lua", api);
unreachable; unreachable;
} }
} }
static void OnlyCallDuringConnection(const char *api) { static void OnlyCallDuringConnection(lua_State *L, const char *api) {
if (!ishandlingconnection) { if (!ishandlingconnection) {
luaL_error(L, "%s() can only be called while handling a connection", api); luaL_error(L, "%s() can only be called while handling a connection", api);
unreachable; unreachable;
} }
} }
static void OnlyCallDuringRequest(const char *api) { static void OnlyCallDuringRequest(lua_State *L, const char *api) {
if (!ishandlingrequest) { if (!ishandlingrequest) {
luaL_error(L, "%s() can only be called while handling a request", api); luaL_error(L, "%s() can only be called while handling a request", api);
unreachable; unreachable;
@ -3022,7 +3022,7 @@ static void OnlyCallDuringRequest(const char *api) {
} }
static int LuaServe(lua_State *L, const char *api, char *impl(void)) { static int LuaServe(lua_State *L, const char *api, char *impl(void)) {
OnlyCallDuringRequest(api); OnlyCallDuringRequest(L, api);
luaheaderp = impl(); luaheaderp = impl();
return 0; return 0;
} }
@ -3039,7 +3039,7 @@ static int LuaServeAsset(lua_State *L) {
size_t pathlen; size_t pathlen;
struct Asset *a; struct Asset *a;
const char *path; const char *path;
OnlyCallDuringRequest("ServeAsset"); OnlyCallDuringRequest(L, "ServeAsset");
path = LuaCheckPath(L, 1, &pathlen); path = LuaCheckPath(L, 1, &pathlen);
if ((a = GetAsset(path, pathlen)) && !S_ISDIR(GetMode(a))) { if ((a = GetAsset(path, pathlen)) && !S_ISDIR(GetMode(a))) {
luaheaderp = ServeAsset(a, path, pathlen); luaheaderp = ServeAsset(a, path, pathlen);
@ -3053,7 +3053,7 @@ static int LuaServeAsset(lua_State *L) {
static int LuaServeIndex(lua_State *L) { static int LuaServeIndex(lua_State *L) {
size_t pathlen; size_t pathlen;
const char *path; const char *path;
OnlyCallDuringRequest("ServeIndex"); OnlyCallDuringRequest(L, "ServeIndex");
path = LuaCheckPath(L, 1, &pathlen); path = LuaCheckPath(L, 1, &pathlen);
lua_pushboolean(L, !!(luaheaderp = ServeIndex(path, pathlen))); lua_pushboolean(L, !!(luaheaderp = ServeIndex(path, pathlen)));
return 1; return 1;
@ -3063,7 +3063,7 @@ static int LuaServeRedirect(lua_State *L) {
size_t loclen; size_t loclen;
const char *location, *eval; const char *location, *eval;
int code; int code;
OnlyCallDuringRequest("ServeRedirect"); OnlyCallDuringRequest(L, "ServeRedirect");
code = luaL_checkinteger(L, 1); code = luaL_checkinteger(L, 1);
if (!(300 <= code && code <= 399)) { if (!(300 <= code && code <= 399)) {
@ -3091,7 +3091,7 @@ static int LuaServeRedirect(lua_State *L) {
static int LuaRoutePath(lua_State *L) { static int LuaRoutePath(lua_State *L) {
size_t pathlen; size_t pathlen;
const char *path; const char *path;
OnlyCallDuringRequest("RoutePath"); OnlyCallDuringRequest(L, "RoutePath");
path = LuaCheckPath(L, 1, &pathlen); path = LuaCheckPath(L, 1, &pathlen);
lua_pushboolean(L, !!(luaheaderp = RoutePath(path, pathlen))); lua_pushboolean(L, !!(luaheaderp = RoutePath(path, pathlen)));
return 1; return 1;
@ -3100,7 +3100,7 @@ static int LuaRoutePath(lua_State *L) {
static int LuaRouteHost(lua_State *L) { static int LuaRouteHost(lua_State *L) {
size_t hostlen, pathlen; size_t hostlen, pathlen;
const char *host, *path; const char *host, *path;
OnlyCallDuringRequest("RouteHost"); OnlyCallDuringRequest(L, "RouteHost");
host = LuaCheckHost(L, 1, &hostlen); host = LuaCheckHost(L, 1, &hostlen);
path = LuaCheckPath(L, 2, &pathlen); path = LuaCheckPath(L, 2, &pathlen);
lua_pushboolean(L, !!(luaheaderp = RouteHost(host, hostlen, path, pathlen))); lua_pushboolean(L, !!(luaheaderp = RouteHost(host, hostlen, path, pathlen)));
@ -3110,7 +3110,7 @@ static int LuaRouteHost(lua_State *L) {
static int LuaRoute(lua_State *L) { static int LuaRoute(lua_State *L) {
size_t hostlen, pathlen; size_t hostlen, pathlen;
const char *host, *path; const char *host, *path;
OnlyCallDuringRequest("Route"); OnlyCallDuringRequest(L, "Route");
host = LuaCheckHost(L, 1, &hostlen); host = LuaCheckHost(L, 1, &hostlen);
path = LuaCheckPath(L, 2, &pathlen); path = LuaCheckPath(L, 2, &pathlen);
lua_pushboolean(L, !!(luaheaderp = Route(host, hostlen, path, pathlen))); lua_pushboolean(L, !!(luaheaderp = Route(host, hostlen, path, pathlen)));
@ -3122,7 +3122,7 @@ static int LuaRespond(lua_State *L, char *R(unsigned, const char *)) {
int code; int code;
size_t reasonlen; size_t reasonlen;
const char *reason; const char *reason;
OnlyCallDuringRequest("Respond"); OnlyCallDuringRequest(L, "Respond");
code = luaL_checkinteger(L, 1); code = luaL_checkinteger(L, 1);
if (!(100 <= code && code <= 999)) { if (!(100 <= code && code <= 999)) {
luaL_argerror(L, 1, "bad status code"); luaL_argerror(L, 1, "bad status code");
@ -3882,7 +3882,7 @@ static int LuaGetDate(lua_State *L) {
} }
static int LuaGetHttpVersion(lua_State *L) { static int LuaGetHttpVersion(lua_State *L) {
OnlyCallDuringRequest("GetHttpVersion"); OnlyCallDuringRequest(L, "GetHttpVersion");
lua_pushinteger(L, msg.version); lua_pushinteger(L, msg.version);
return 1; return 1;
} }
@ -3893,7 +3893,7 @@ static int LuaGetRedbeanVersion(lua_State *L) {
} }
static int LuaGetMethod(lua_State *L) { static int LuaGetMethod(lua_State *L) {
OnlyCallDuringRequest("GetMethod"); OnlyCallDuringRequest(L, "GetMethod");
if (msg.method) { if (msg.method) {
lua_pushstring(L, kHttpMethod[msg.method]); lua_pushstring(L, kHttpMethod[msg.method]);
} else { } else {
@ -3912,17 +3912,17 @@ static int LuaGetAddr(lua_State *L, void GetAddr(uint32_t *, uint16_t *)) {
} }
static int LuaGetServerAddr(lua_State *L) { static int LuaGetServerAddr(lua_State *L) {
OnlyCallDuringConnection("GetServerAddr"); OnlyCallDuringConnection(L, "GetServerAddr");
return LuaGetAddr(L, GetServerAddr); return LuaGetAddr(L, GetServerAddr);
} }
static int LuaGetClientAddr(lua_State *L) { static int LuaGetClientAddr(lua_State *L) {
OnlyCallDuringConnection("GetClientAddr"); OnlyCallDuringConnection(L, "GetClientAddr");
return LuaGetAddr(L, GetClientAddr); return LuaGetAddr(L, GetClientAddr);
} }
static int LuaGetRemoteAddr(lua_State *L) { static int LuaGetRemoteAddr(lua_State *L) {
OnlyCallDuringRequest("GetRemoteAddr"); OnlyCallDuringRequest(L, "GetRemoteAddr");
return LuaGetAddr(L, GetRemoteAddr); return LuaGetAddr(L, GetRemoteAddr);
} }
@ -3968,7 +3968,7 @@ static int LuaCategorizeIp(lua_State *L) {
static int LuaGetUrl(lua_State *L) { static int LuaGetUrl(lua_State *L) {
char *p; char *p;
size_t n; size_t n;
OnlyCallDuringRequest("GetUrl"); OnlyCallDuringRequest(L, "GetUrl");
p = EncodeUrl(&url, &n); p = EncodeUrl(&url, &n);
lua_pushlstring(L, p, n); lua_pushlstring(L, p, n);
free(p); free(p);
@ -3984,25 +3984,25 @@ static void LuaPushUrlView(lua_State *L, struct UrlView *v) {
} }
static int LuaGetScheme(lua_State *L) { static int LuaGetScheme(lua_State *L) {
OnlyCallDuringRequest("GetScheme"); OnlyCallDuringRequest(L, "GetScheme");
LuaPushUrlView(L, &url.scheme); LuaPushUrlView(L, &url.scheme);
return 1; return 1;
} }
static int LuaGetPath(lua_State *L) { static int LuaGetPath(lua_State *L) {
OnlyCallDuringRequest("GetPath"); OnlyCallDuringRequest(L, "GetPath");
LuaPushUrlView(L, &url.path); LuaPushUrlView(L, &url.path);
return 1; return 1;
} }
static int LuaGetEffectivePath(lua_State *L) { static int LuaGetEffectivePath(lua_State *L) {
OnlyCallDuringRequest("GetEffectivePath"); OnlyCallDuringRequest(L, "GetEffectivePath");
lua_pushlstring(L, effectivepath.p, effectivepath.n); lua_pushlstring(L, effectivepath.p, effectivepath.n);
return 1; return 1;
} }
static int LuaGetFragment(lua_State *L) { static int LuaGetFragment(lua_State *L) {
OnlyCallDuringRequest("GetFragment"); OnlyCallDuringRequest(L, "GetFragment");
LuaPushUrlView(L, &url.fragment); LuaPushUrlView(L, &url.fragment);
return 1; return 1;
} }
@ -4010,7 +4010,7 @@ static int LuaGetFragment(lua_State *L) {
static int LuaGetUser(lua_State *L) { static int LuaGetUser(lua_State *L) {
size_t n; size_t n;
const char *p, *q; const char *p, *q;
OnlyCallDuringRequest("GetUser"); OnlyCallDuringRequest(L, "GetUser");
if (url.user.p) { if (url.user.p) {
LuaPushUrlView(L, &url.user); LuaPushUrlView(L, &url.user);
} else if ((p = GetBasicAuthorization(&n))) { } else if ((p = GetBasicAuthorization(&n))) {
@ -4026,7 +4026,7 @@ static int LuaGetUser(lua_State *L) {
static int LuaGetPass(lua_State *L) { static int LuaGetPass(lua_State *L) {
size_t n; size_t n;
const char *p, *q; const char *p, *q;
OnlyCallDuringRequest("GetPass"); OnlyCallDuringRequest(L, "GetPass");
if (url.user.p) { if (url.user.p) {
LuaPushUrlView(L, &url.pass); LuaPushUrlView(L, &url.pass);
} else if ((p = GetBasicAuthorization(&n))) { } else if ((p = GetBasicAuthorization(&n))) {
@ -4044,7 +4044,7 @@ static int LuaGetPass(lua_State *L) {
static int LuaGetHost(lua_State *L) { static int LuaGetHost(lua_State *L) {
char b[16]; char b[16];
OnlyCallDuringRequest("GetHost"); OnlyCallDuringRequest(L, "GetHost");
if (url.host.n) { if (url.host.n) {
lua_pushlstring(L, url.host.p, url.host.n); lua_pushlstring(L, url.host.p, url.host.n);
} else { } else {
@ -4056,7 +4056,7 @@ static int LuaGetHost(lua_State *L) {
static int LuaGetPort(lua_State *L) { static int LuaGetPort(lua_State *L) {
int i, x = 0; int i, x = 0;
OnlyCallDuringRequest("GetPort"); OnlyCallDuringRequest(L, "GetPort");
for (i = 0; i < url.port.n; ++i) x = url.port.p[i] - '0' + x * 10; for (i = 0; i < url.port.n; ++i) x = url.port.p[i] - '0' + x * 10;
if (!x) x = ntohs(serveraddr->sin_port); if (!x) x = ntohs(serveraddr->sin_port);
lua_pushinteger(L, x); lua_pushinteger(L, x);
@ -4086,7 +4086,7 @@ static int LuaGetHeader(lua_State *L) {
int h; int h;
const char *key; const char *key;
size_t i, keylen; size_t i, keylen;
OnlyCallDuringRequest("GetHeader"); OnlyCallDuringRequest(L, "GetHeader");
key = luaL_checklstring(L, 1, &keylen); key = luaL_checklstring(L, 1, &keylen);
if ((h = GetHttpHeader(key, keylen)) != -1) { if ((h = GetHttpHeader(key, keylen)) != -1) {
if (msg.headers[h].a) { if (msg.headers[h].a) {
@ -4107,7 +4107,7 @@ static int LuaGetHeader(lua_State *L) {
} }
static int LuaGetHeaders(lua_State *L) { static int LuaGetHeaders(lua_State *L) {
OnlyCallDuringRequest("GetHeaders"); OnlyCallDuringRequest(L, "GetHeaders");
return LuaPushHeaders(L, &msg, inbuf.p); return LuaPushHeaders(L, &msg, inbuf.p);
} }
@ -4117,7 +4117,7 @@ static int LuaSetHeader(lua_State *L) {
char *p, *q; char *p, *q;
const char *key, *val, *eval; const char *key, *val, *eval;
size_t i, keylen, vallen, evallen; size_t i, keylen, vallen, evallen;
OnlyCallDuringRequest("SetHeader"); OnlyCallDuringRequest(L, "SetHeader");
key = luaL_checklstring(L, 1, &keylen); key = luaL_checklstring(L, 1, &keylen);
val = luaL_checklstring(L, 2, &vallen); val = luaL_checklstring(L, 2, &vallen);
if ((h = GetHttpHeader(key, keylen)) == -1) { if ((h = GetHttpHeader(key, keylen)) == -1) {
@ -4166,7 +4166,7 @@ static int LuaSetHeader(lua_State *L) {
static int LuaGetCookie(lua_State *L) { static int LuaGetCookie(lua_State *L) {
char *cookie = 0, *cookietmpl, *cookieval; char *cookie = 0, *cookietmpl, *cookieval;
OnlyCallDuringRequest("GetCookie"); OnlyCallDuringRequest(L, "GetCookie");
cookietmpl = gc(xasprintf(" %s=", luaL_checkstring(L, 1))); cookietmpl = gc(xasprintf(" %s=", luaL_checkstring(L, 1)));
if (HasHeader(kHttpCookie)) { if (HasHeader(kHttpCookie)) {
@ -4192,7 +4192,7 @@ static int LuaSetCookie(lua_State *L) {
const char *hostpref = "__Host-"; const char *hostpref = "__Host-";
const char *securepref = "__Secure-"; const char *securepref = "__Secure-";
OnlyCallDuringRequest("SetCookie"); OnlyCallDuringRequest(L, "SetCookie");
key = luaL_checklstring(L, 1, &keylen); key = luaL_checklstring(L, 1, &keylen);
val = luaL_checklstring(L, 2, &vallen); val = luaL_checklstring(L, 2, &vallen);
@ -4292,7 +4292,7 @@ static int LuaSetCookie(lua_State *L) {
static int LuaHasParam(lua_State *L) { static int LuaHasParam(lua_State *L) {
size_t i, n; size_t i, n;
const char *s; const char *s;
OnlyCallDuringRequest("HasParam"); OnlyCallDuringRequest(L, "HasParam");
s = luaL_checklstring(L, 1, &n); s = luaL_checklstring(L, 1, &n);
for (i = 0; i < url.params.n; ++i) { for (i = 0; i < url.params.n; ++i) {
if (SlicesEqual(s, n, url.params.p[i].key.p, url.params.p[i].key.n)) { if (SlicesEqual(s, n, url.params.p[i].key.p, url.params.p[i].key.n)) {
@ -4307,7 +4307,7 @@ static int LuaHasParam(lua_State *L) {
static int LuaGetParam(lua_State *L) { static int LuaGetParam(lua_State *L) {
size_t i, n; size_t i, n;
const char *s; const char *s;
OnlyCallDuringRequest("GetParam"); OnlyCallDuringRequest(L, "GetParam");
s = luaL_checklstring(L, 1, &n); s = luaL_checklstring(L, 1, &n);
for (i = 0; i < url.params.n; ++i) { for (i = 0; i < url.params.n; ++i) {
if (SlicesEqual(s, n, url.params.p[i].key.p, url.params.p[i].key.n)) { if (SlicesEqual(s, n, url.params.p[i].key.p, url.params.p[i].key.n)) {
@ -4339,7 +4339,7 @@ static void LuaPushUrlParams(lua_State *L, struct UrlParams *h) {
} }
static int LuaGetParams(lua_State *L) { static int LuaGetParams(lua_State *L) {
OnlyCallDuringRequest("GetParams"); OnlyCallDuringRequest(L, "GetParams");
LuaPushUrlParams(L, &url.params); LuaPushUrlParams(L, &url.params);
return 1; return 1;
} }
@ -4455,7 +4455,7 @@ static int LuaEncodeUrl(lua_State *L) {
static int LuaWrite(lua_State *L) { static int LuaWrite(lua_State *L) {
size_t size; size_t size;
const char *data; const char *data;
OnlyCallDuringRequest("Write"); OnlyCallDuringRequest(L, "Write");
if (!lua_isnil(L, 1)) { if (!lua_isnil(L, 1)) {
data = luaL_checklstring(L, 1, &size); data = luaL_checklstring(L, 1, &size);
appendd(&outbuf, data, size); appendd(&outbuf, data, size);
@ -4754,32 +4754,32 @@ static noinline int LuaProgramInt(lua_State *L, void P(long)) {
} }
static int LuaProgramPort(lua_State *L) { static int LuaProgramPort(lua_State *L) {
OnlyCallFromInitLua("ProgramPort"); OnlyCallFromInitLua(L, "ProgramPort");
return LuaProgramInt(L, ProgramPort); return LuaProgramInt(L, ProgramPort);
} }
static int LuaProgramCache(lua_State *L) { static int LuaProgramCache(lua_State *L) {
OnlyCallFromInitLua("ProgramCache"); OnlyCallFromInitLua(L, "ProgramCache");
return LuaProgramInt(L, ProgramCache); return LuaProgramInt(L, ProgramCache);
} }
static int LuaProgramTimeout(lua_State *L) { static int LuaProgramTimeout(lua_State *L) {
OnlyCallFromInitLua("ProgramTimeout"); OnlyCallFromInitLua(L, "ProgramTimeout");
return LuaProgramInt(L, ProgramTimeout); return LuaProgramInt(L, ProgramTimeout);
} }
static int LuaProgramUid(lua_State *L) { static int LuaProgramUid(lua_State *L) {
OnlyCallFromInitLua("ProgramUid"); OnlyCallFromInitLua(L, "ProgramUid");
return LuaProgramInt(L, ProgramUid); return LuaProgramInt(L, ProgramUid);
} }
static int LuaProgramGid(lua_State *L) { static int LuaProgramGid(lua_State *L) {
OnlyCallFromInitLua("ProgramGid"); OnlyCallFromInitLua(L, "ProgramGid");
return LuaProgramInt(L, ProgramGid); return LuaProgramInt(L, ProgramGid);
} }
static int LuaProgramSslTicketLifetime(lua_State *L) { static int LuaProgramSslTicketLifetime(lua_State *L) {
OnlyCallFromInitLua("ProgramSslTicketLifetime"); OnlyCallFromInitLua(L, "ProgramSslTicketLifetime");
return LuaProgramInt(L, ProgramSslTicketLifetime); return LuaProgramInt(L, ProgramSslTicketLifetime);
} }
@ -4789,12 +4789,12 @@ static noinline int LuaProgramString(lua_State *L, void P(const char *)) {
} }
static int LuaProgramAddr(lua_State *L) { static int LuaProgramAddr(lua_State *L) {
OnlyCallFromInitLua("ProgramAddr"); OnlyCallFromInitLua(L, "ProgramAddr");
return LuaProgramString(L, ProgramAddr); return LuaProgramString(L, ProgramAddr);
} }
static int LuaProgramBrand(lua_State *L) { static int LuaProgramBrand(lua_State *L) {
OnlyCallFromInitLua("ProgramBrand"); OnlyCallFromInitLua(L, "ProgramBrand");
return LuaProgramString(L, ProgramBrand); return LuaProgramString(L, ProgramBrand);
} }
@ -4803,12 +4803,12 @@ static int LuaProgramDirectory(lua_State *L) {
} }
static int LuaProgramLogPath(lua_State *L) { static int LuaProgramLogPath(lua_State *L) {
OnlyCallFromInitLua("ProgramLogPath"); OnlyCallFromInitLua(L, "ProgramLogPath");
return LuaProgramString(L, ProgramLogPath); return LuaProgramString(L, ProgramLogPath);
} }
static int LuaProgramPidPath(lua_State *L) { static int LuaProgramPidPath(lua_State *L) {
OnlyCallFromInitLua("ProgramPidPath"); OnlyCallFromInitLua(L, "ProgramPidPath");
return LuaProgramString(L, ProgramPidPath); return LuaProgramString(L, ProgramPidPath);
} }
@ -4817,7 +4817,7 @@ static int LuaProgramSslPresharedKey(lua_State *L) {
struct Psk psk; struct Psk psk;
size_t n1, n2, i; size_t n1, n2, i;
const char *p1, *p2; const char *p1, *p2;
OnlyCallFromInitLua("ProgramSslPresharedKey"); OnlyCallFromInitLua(L, "ProgramSslPresharedKey");
p1 = luaL_checklstring(L, 1, &n1); p1 = luaL_checklstring(L, 1, &n1);
p2 = luaL_checklstring(L, 2, &n2); p2 = luaL_checklstring(L, 2, &n2);
if (!n1 || n1 > MBEDTLS_PSK_MAX_LEN || !n2) { if (!n1 || n1 > MBEDTLS_PSK_MAX_LEN || !n2) {
@ -4860,7 +4860,7 @@ static int LuaProgramPrivateKey(lua_State *L) {
#ifndef UNSECURE #ifndef UNSECURE
size_t n; size_t n;
const char *p; const char *p;
OnlyCallFromInitLua("ProgramPrivateKey"); OnlyCallFromInitLua(L, "ProgramPrivateKey");
p = luaL_checklstring(L, 1, &n); p = luaL_checklstring(L, 1, &n);
ProgramPrivateKey(p, n); ProgramPrivateKey(p, n);
#endif #endif
@ -4871,7 +4871,7 @@ static int LuaProgramCertificate(lua_State *L) {
#ifndef UNSECURE #ifndef UNSECURE
size_t n; size_t n;
const char *p; const char *p;
OnlyCallFromInitLua("ProgramCertificate"); OnlyCallFromInitLua(L, "ProgramCertificate");
p = luaL_checklstring(L, 1, &n); p = luaL_checklstring(L, 1, &n);
ProgramCertificate(p, n); ProgramCertificate(p, n);
#endif #endif
@ -4900,12 +4900,12 @@ static noinline int LuaProgramBool(lua_State *L, bool *b) {
} }
static int LuaProgramSslClientVerify(lua_State *L) { static int LuaProgramSslClientVerify(lua_State *L) {
OnlyCallFromInitLua("ProgramSslClientVerify"); OnlyCallFromInitLua(L, "ProgramSslClientVerify");
return LuaProgramBool(L, &sslclientverify); return LuaProgramBool(L, &sslclientverify);
} }
static int LuaProgramSslFetchVerify(lua_State *L) { static int LuaProgramSslFetchVerify(lua_State *L) {
OnlyCallFromInitLua("ProgramSslFetchVerify"); OnlyCallFromInitLua(L, "ProgramSslFetchVerify");
return LuaProgramBool(L, &sslfetchverify); return LuaProgramBool(L, &sslfetchverify);
} }
@ -4918,13 +4918,13 @@ static int LuaProgramLogBodies(lua_State *L) {
} }
static int LuaEvadeDragnetSurveillance(lua_State *L) { static int LuaEvadeDragnetSurveillance(lua_State *L) {
OnlyCallFromInitLua("EvadeDragnetSurveillance"); OnlyCallFromInitLua(L, "EvadeDragnetSurveillance");
return LuaProgramBool(L, &evadedragnetsurveillance); return LuaProgramBool(L, &evadedragnetsurveillance);
} }
static int LuaProgramSslCompression(lua_State *L) { static int LuaProgramSslCompression(lua_State *L) {
#ifndef UNSECURE #ifndef UNSECURE
OnlyCallFromInitLua("ProgramSslCompression"); OnlyCallFromInitLua(L, "ProgramSslCompression");
conf.disable_compression = confcli.disable_compression = !lua_toboolean(L, 1); conf.disable_compression = confcli.disable_compression = !lua_toboolean(L, 1);
#endif #endif
return 0; return 0;
@ -5118,7 +5118,7 @@ static void LuaSetIntField(lua_State *L, const char *k, lua_Integer v) {
} }
static int LuaLaunchBrowser(lua_State *L) { static int LuaLaunchBrowser(lua_State *L) {
OnlyCallFromInitLua("LaunchBrowser"); OnlyCallFromInitLua(L, "LaunchBrowser");
launchbrowser = strdup(luaL_optstring(L, 1, "/")); launchbrowser = strdup(luaL_optstring(L, 1, "/"));
return 0; return 0;
} }