Skip to content

Commit

Permalink
zero message header before sending/receiving on luasocket
Browse files Browse the repository at this point in the history
  • Loading branch information
lneto committed Dec 9, 2023
1 parent ee8a9f0 commit 1993d76
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/luasocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ static int luasocket_close(lua_State *L)
return 0;
}

#define luasocket_setmsg(m) memset(&(m), 0, sizeof(m))

static int luasocket_send(lua_State *L)
{
struct socket *socket = luasocket_checksocket(L, 1);
Expand All @@ -141,6 +143,8 @@ static int luasocket_send(lua_State *L)
int nargs = lua_gettop(L);
int ret;

luasocket_setmsg(msg);

vec.iov_base = (void *)luaL_checklstring(L, 2, &len);
vec.iov_len = len;

Expand All @@ -167,6 +171,8 @@ static int luasocket_receive(lua_State *L)
int from = lua_toboolean(L, 4);
int ret;

luasocket_setmsg(msg);

vec.iov_base = (void *)luaL_buffinitsize(L, &B, len);
vec.iov_len = len;

Expand Down

0 comments on commit 1993d76

Please sign in to comment.