Skip to content

Commit db28b92

Browse files
Yasuhiro KimuraYasuhiro Kimura
Yasuhiro Kimura
authored and
Yasuhiro Kimura
committed
mail/opendkim-devel: Add patch to fix bug related to Lua
PR: 279811 Reported by: Yasuhito FUTATSUKI Obtained from: trusteddomainproject/OpenDKIM#201
1 parent d5e066b commit db28b92

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

mail/opendkim-devel/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ PORTNAME= opendkim
22
DISTVERSIONPREFIX= rel-opendkim-
33
DISTVERSION= 2.11.0-Beta2-48
44
DISTVERSIONSUFFIX= -g551ab382
5+
PORTREVISION= 1
56
CATEGORIES= mail security
67
PKGNAMESUFFIX= -devel
78

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
From 57b86d35381ed9bfb7e4be4e6512fb64163dd725 Mon Sep 17 00:00:00 2001
2+
From: FUTATSUKI Yasuhito <[email protected]>
3+
Date: Tue, 27 Feb 2024 14:41:59 +0900
4+
Subject: [PATCH] Lua: Fix stack level after register odkim functions.
5+
6+
When luaL_setfuncs() is replaced by luaL_newlib() + lua_setglobal()
7+
in commit 74b3374feee34fba14a0e15f89f049cbe4a3dafd, the commit did
8+
not take account that lua_setglobal() pops a value from the stack.
9+
10+
Thus, following lua pop(l, 1) tries to pop from empty stack in
11+
Lua >= 5.2, especially in Lua 5.4, it causes abort().
12+
13+
This fix it.
14+
15+
* miltertest/miltertest.c (main):
16+
Don't pop after lua_setglobal() in Lua >= 5.2
17+
18+
* opendkim/opendkim-lua.c
19+
(dkimf_lua_setup_hook, dkimf_lua_screen_hook,
20+
dkimf_lua_stats_hook, dkimf_lua_final_hook): As above.
21+
---
22+
miltertest/miltertest.c | 2 +-
23+
opendkim/opendkim-lua.c | 8 ++++----
24+
2 files changed, 5 insertions(+), 5 deletions(-)
25+
26+
diff --git miltertest/miltertest.c miltertest/miltertest.c
27+
index b4a345f7..339cfa91 100644
28+
--- miltertest/miltertest.c
29+
+++ miltertest/miltertest.c
30+
@@ -4014,8 +4014,8 @@ main(int argc, char **argv)
31+
lua_setglobal(l, "mt");
32+
#else /* LUA_VERSION_NUM >= 502 */
33+
luaL_register(l, "mt", mt_library);
34+
-#endif /* LUA_VERSION_NUM >= 502 */
35+
lua_pop(l, 1);
36+
+#endif /* LUA_VERSION_NUM >= 502 */
37+
38+
/* register constants */
39+
lua_pushnumber(l, MT_HDRINSERT);
40+
diff --git opendkim/opendkim-lua.c opendkim/opendkim-lua.c
41+
index 3786aa4b..c1a67f90 100644
42+
--- opendkim/opendkim-lua.c
43+
+++ opendkim/opendkim-lua.c
44+
@@ -490,8 +490,8 @@ dkimf_lua_setup_hook(void *ctx, const char *script, size_t scriptlen,
45+
lua_setglobal(l, "odkim");
46+
# else /* LUA_VERSION_NUM >= 502 */
47+
luaL_register(l, "odkim", dkimf_lua_lib_setup);
48+
-# endif /* LUA_VERSION_NUM >= 502 */
49+
lua_pop(l, 1);
50+
+# endif /* LUA_VERSION_NUM >= 502 */
51+
52+
/*
53+
** Register constants.
54+
@@ -649,8 +649,8 @@ dkimf_lua_screen_hook(void *ctx, const char *script, size_t scriptlen,
55+
lua_setglobal(l, "odkim");
56+
# else /* LUA_VERSION_NUM >= 502 */
57+
luaL_register(l, "odkim", dkimf_lua_lib_screen);
58+
-# endif /* LUA_VERSION_NUM >= 502 */
59+
lua_pop(l, 1);
60+
+# endif /* LUA_VERSION_NUM >= 502 */
61+
62+
/*
63+
** Register constants.
64+
@@ -798,8 +798,8 @@ dkimf_lua_stats_hook(void *ctx, const char *script, size_t scriptlen,
65+
lua_setglobal(l, "odkim");
66+
# else /* LUA_VERSION_NUM >= 502 */
67+
luaL_register(l, "odkim", dkimf_lua_lib_stats);
68+
-# endif /* LUA_VERSION_NUM >= 502 */
69+
lua_pop(l, 1);
70+
+# endif /* LUA_VERSION_NUM >= 502 */
71+
72+
/*
73+
** Register constants.
74+
@@ -1039,8 +1039,8 @@ dkimf_lua_final_hook(void *ctx, const char *script, size_t scriptlen,
75+
lua_setglobal(l, "odkim");
76+
# else /* LUA_VERSION_NUM >= 502 */
77+
luaL_register(l, "odkim", dkimf_lua_lib_final);
78+
-# endif /* LUA_VERSION_NUM >= 502 */
79+
lua_pop(l, 1);
80+
+# endif /* LUA_VERSION_NUM >= 502 */
81+
82+
/*
83+
** Register constants.
84+
--
85+
2.45.2
86+

0 commit comments

Comments
 (0)