Browse Source

Fixed message buffer overflow bug.

master
Jiaojinxing 5 years ago
parent
commit
44b388a939
  1. 8
      luasocket/src/options.c

8
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)) while (opt->name && strcmp(name, opt->name))
opt++; opt++;
if (!opt->func) { if (!opt->func) {
char msg[45]; char msg[64];
sprintf(msg, "unsupported option `%.35s'", name); snprintf(msg, sizeof(msg), "unsupported option `%.35s'", name);
luaL_argerror(L, 2, msg); luaL_argerror(L, 2, msg);
} }
return opt->func(L, ps); 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)) while (opt->name && strcmp(name, opt->name))
opt++; opt++;
if (!opt->func) { if (!opt->func) {
char msg[45]; char msg[64];
sprintf(msg, "unsupported option `%.35s'", name); snprintf(msg, sizeof(msg), "unsupported option `%.35s'", name);
luaL_argerror(L, 2, msg); luaL_argerror(L, 2, msg);
} }
return opt->func(L, ps); return opt->func(L, ps);

Loading…
Cancel
Save