Skip to content

Conversation

@qrsikno2
Copy link
Contributor

@qrsikno2 qrsikno2 commented Aug 7, 2025

This pull request introduces a small but important change to the luanetfilter_hook_cb function in lib/luanetfilter.c. The update ensures that the data structure is cleared before further processing, which can help prevent issues caused by stale or leftover data.

  • Added a call to luadata_clear(data); at the beginning of the function to ensure the data structure is reset before use.

@qrsikno2 qrsikno2 requested review from lneto and sheharyaar August 7, 2025 15:37
lib/luaxtable.c Outdated
int ret = lua_toboolean(L, -1);
lua_getfield(L, -2, "hotdrop");
par->hotdrop = lua_toboolean(L, -1);
luadata_clear(xtable->skb);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should clear just after the call.. on either case.. success or error.. perhaps a better approach is to move the cleanup to luaxtable_call..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed. but there has some typecast in original commit. so i have to add an extra function to typecast it back, otherwise the luadata_clear wouldn't accept it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need a function? just put a typecast inline..


#define luaxtable_call(L, op, xtable, skb, par, info, opt) \
((luaxtable_pushparams(L, par, xtable, skb, opt) == -1) || (luaxtable_docall(L, xtable, info, op, 2, 1) == -1))
((luaxtable_pushparams(L, par, xtable, skb, opt) == -1) || (luaxtable_docall(L, xtable, info, op, 2, 1) == -1) || luaxtable_cleanup(xtable))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will only be called in case of success, right? as I mentioned, both cases should be handled

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, the best approach is to move the luadata_clear() call to luaxtable_docall() body..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants