From 44b388a939160683337195ec53a55d1f17d03b6a Mon Sep 17 00:00:00 2001 From: Jiaojinxing Date: Thu, 19 Mar 2020 16:56:27 +0800 Subject: [PATCH] Fixed message buffer overflow bug. --- luasocket/src/options.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/luasocket/src/options.c b/luasocket/src/options.c index 20f4c28..668cc80 100644 --- a/luasocket/src/options.c +++ b/luasocket/src/options.c @@ -37,8 +37,8 @@ int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps) while (opt->name && strcmp(name, opt->name)) opt++; if (!opt->func) { - char msg[45]; - sprintf(msg, "unsupported option `%.35s'", name); + char msg[64]; + snprintf(msg, sizeof(msg), "unsupported option `%.35s'", name); luaL_argerror(L, 2, msg); } return opt->func(L, ps); @@ -50,8 +50,8 @@ int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps) while (opt->name && strcmp(name, opt->name)) opt++; if (!opt->func) { - char msg[45]; - sprintf(msg, "unsupported option `%.35s'", name); + char msg[64]; + snprintf(msg, sizeof(msg), "unsupported option `%.35s'", name); luaL_argerror(L, 2, msg); } return opt->func(L, ps);