s3/util/py_net.c: fix samba-tool domain join&leave segfault
commit976326fa2b6423ac5866af682605cf7584e4991a
authorMichael Tokarev <mjt@tls.msk.ru>
Tue, 24 May 2022 13:25:41 +0000 (24 16:25 +0300)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 25 May 2022 06:19:32 +0000 (25 06:19 +0000)
tree2c0b5b0aeec229b22d265d2f284fa95a15489b40
parent56e179817123b40c3646476563d345d8f97efff9
s3/util/py_net.c: fix samba-tool domain join&leave segfault

We process python args using PyArg_ParseTupleAndKeywords(), and use "p"
type modifier there.  According to documentation, this type modifier,
while works for a boolean type, expects an argument of type int. But in
py_net_join_member() and  py_net_leave() we use argument of type uint8_t
(no_dns_update, keep_account, r->in.debug). So when PyArg_ParseTupleAndKeywords()
tries to assign a value to &no_dns_update, it updates subsequent, unrelated bytes
too, - which ones depends on the stack and structure layout used by the compiler.

Fix this by using int type for all relevant variables, and by introducing proxy
variable "debug" (of the same type) for r->in.debug.

While at it, also ensure all variables have sensible default values.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed May 25 06:19:32 UTC 2022 on sn-devel-184
source3/utils/py_net.c