-
Notifications
You must be signed in to change notification settings - Fork 41
add luadata_clear for netfilter & xtable #315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
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); |
There was a problem hiding this comment.
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..
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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..
This pull request introduces a small but important change to the
luanetfilter_hook_cbfunction inlib/luanetfilter.c. The update ensures that thedatastructure is cleared before further processing, which can help prevent issues caused by stale or leftover data.luadata_clear(data);at the beginning of the function to ensure thedatastructure is reset before use.