mirror of
https://github.com/samba-team/samba.git
synced 2025-08-04 08:22:08 +03:00
libsmbclient: Wrap more function calls in talloc_stackframe() to protect against talloc_tos() calls
BUG: https://bugzilla.samba.org/show_bug.cgi?id=8449 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed Apr 2 02:36:08 CEST 2014 on sn-devel-104
This commit is contained in:
committed by
Jeremy Allison
parent
8f3a516acb
commit
014342746f
@ -560,6 +560,7 @@ SMBCCTX *
|
|||||||
smbc_init_context(SMBCCTX *context)
|
smbc_init_context(SMBCCTX *context)
|
||||||
{
|
{
|
||||||
int pid;
|
int pid;
|
||||||
|
TALLOC_CTX *frame;
|
||||||
|
|
||||||
if (!context) {
|
if (!context) {
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
@ -571,11 +572,14 @@ smbc_init_context(SMBCCTX *context)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frame = talloc_stackframe();
|
||||||
|
|
||||||
if ((!smbc_getFunctionAuthData(context) &&
|
if ((!smbc_getFunctionAuthData(context) &&
|
||||||
!smbc_getFunctionAuthDataWithContext(context)) ||
|
!smbc_getFunctionAuthDataWithContext(context)) ||
|
||||||
smbc_getDebug(context) < 0 ||
|
smbc_getDebug(context) < 0 ||
|
||||||
smbc_getDebug(context) > 100) {
|
smbc_getDebug(context) > 100) {
|
||||||
|
|
||||||
|
TALLOC_FREE(frame);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -594,6 +598,7 @@ smbc_init_context(SMBCCTX *context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
|
TALLOC_FREE(frame);
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -602,6 +607,7 @@ smbc_init_context(SMBCCTX *context)
|
|||||||
SAFE_FREE(user);
|
SAFE_FREE(user);
|
||||||
|
|
||||||
if (!smbc_getUser(context)) {
|
if (!smbc_getUser(context)) {
|
||||||
|
TALLOC_FREE(frame);
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -624,6 +630,7 @@ smbc_init_context(SMBCCTX *context)
|
|||||||
pid = getpid();
|
pid = getpid();
|
||||||
netbios_name = (char *)SMB_MALLOC(17);
|
netbios_name = (char *)SMB_MALLOC(17);
|
||||||
if (!netbios_name) {
|
if (!netbios_name) {
|
||||||
|
TALLOC_FREE(frame);
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -632,6 +639,7 @@ smbc_init_context(SMBCCTX *context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!netbios_name) {
|
if (!netbios_name) {
|
||||||
|
TALLOC_FREE(frame);
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -640,6 +648,7 @@ smbc_init_context(SMBCCTX *context)
|
|||||||
SAFE_FREE(netbios_name);
|
SAFE_FREE(netbios_name);
|
||||||
|
|
||||||
if (!smbc_getNetbiosName(context)) {
|
if (!smbc_getNetbiosName(context)) {
|
||||||
|
TALLOC_FREE(frame);
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -659,6 +668,7 @@ smbc_init_context(SMBCCTX *context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!workgroup) {
|
if (!workgroup) {
|
||||||
|
TALLOC_FREE(frame);
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -667,6 +677,7 @@ smbc_init_context(SMBCCTX *context)
|
|||||||
SAFE_FREE(workgroup);
|
SAFE_FREE(workgroup);
|
||||||
|
|
||||||
if (!smbc_getWorkgroup(context)) {
|
if (!smbc_getWorkgroup(context)) {
|
||||||
|
TALLOC_FREE(frame);
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -692,6 +703,7 @@ smbc_init_context(SMBCCTX *context)
|
|||||||
smb_panic("error unlocking 'initialized_ctx_count'");
|
smb_panic("error unlocking 'initialized_ctx_count'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TALLOC_FREE(frame);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -727,12 +739,15 @@ void smbc_set_credentials_with_fallback(SMBCCTX *context,
|
|||||||
smbc_bool use_kerberos = false;
|
smbc_bool use_kerberos = false;
|
||||||
const char *signing_state = "off";
|
const char *signing_state = "off";
|
||||||
struct user_auth_info *auth_info = NULL;
|
struct user_auth_info *auth_info = NULL;
|
||||||
|
TALLOC_CTX *frame;
|
||||||
|
|
||||||
if (! context) {
|
if (! context) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frame = talloc_stackframe();
|
||||||
|
|
||||||
if (! workgroup || ! *workgroup) {
|
if (! workgroup || ! *workgroup) {
|
||||||
workgroup = smbc_getWorkgroup(context);
|
workgroup = smbc_getWorkgroup(context);
|
||||||
}
|
}
|
||||||
@ -749,6 +764,7 @@ void smbc_set_credentials_with_fallback(SMBCCTX *context,
|
|||||||
|
|
||||||
if (! auth_info) {
|
if (! auth_info) {
|
||||||
DEBUG(0, ("smbc_set_credentials_with_fallback: allocation fail\n"));
|
DEBUG(0, ("smbc_set_credentials_with_fallback: allocation fail\n"));
|
||||||
|
TALLOC_FREE(frame);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -777,4 +793,5 @@ void smbc_set_credentials_with_fallback(SMBCCTX *context,
|
|||||||
TALLOC_FREE(context->internal->auth_info);
|
TALLOC_FREE(context->internal->auth_info);
|
||||||
|
|
||||||
context->internal->auth_info = auth_info;
|
context->internal->auth_info = auth_info;
|
||||||
|
TALLOC_FREE(frame);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user