1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

lib: Make callers of base64_encode_data_blob check for success

Quite a few callers already did check for !=NULL. With the current code this is
pointless due to a SMB_ASSERT in base64_encode_data_blob() itself. Make the
callers consistently check, so that we can remove SMB_ASSERT from base64.c.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2016-05-03 15:54:07 +02:00 committed by Jeremy Allison
parent f457535e33
commit cf5a81013d
5 changed files with 32 additions and 13 deletions

View File

@ -1240,10 +1240,14 @@ static NTSTATUS sam_account_from_object(struct samu *account,
}
if (userParameters.data) {
char *newstr;
char *newstr = NULL;
old_string = pdb_get_munged_dial(account);
newstr = (userParameters.length == 0) ? NULL :
base64_encode_data_blob(talloc_tos(), userParameters);
if (userParameters.length != 0) {
newstr = base64_encode_data_blob(talloc_tos(),
userParameters);
SMB_ASSERT(newstr != NULL);
}
if (STRING_CHANGED_NC(old_string, newstr))
pdb_set_munged_dial(account, newstr, PDB_CHANGED);

View File

@ -126,12 +126,15 @@ static NTSTATUS sam_account_from_delta(struct samu *account,
if (r->parameters.array) {
DATA_BLOB mung;
char *newstr;
char *newstr = NULL;
old_string = pdb_get_munged_dial(account);
mung.length = r->parameters.length * 2;
mung.data = (uint8_t *) r->parameters.array;
newstr = (mung.length == 0) ? NULL :
base64_encode_data_blob(talloc_tos(), mung);
if (mung.length != 0) {
newstr = base64_encode_data_blob(talloc_tos(), mung);
SMB_ASSERT(newstr != NULL);
}
if (STRING_CHANGED_NC(old_string, newstr))
pdb_set_munged_dial(account, newstr, PDB_CHANGED);

View File

@ -305,8 +305,6 @@ void copy_id18_to_sam_passwd(struct samu *to,
void copy_id20_to_sam_passwd(struct samu *to,
struct samr_UserInfo20 *from)
{
const char *old_string;
char *new_string;
DATA_BLOB mung;
if (from == NULL || to == NULL) {
@ -314,11 +312,18 @@ void copy_id20_to_sam_passwd(struct samu *to,
}
if (from->parameters.array) {
const char *old_string;
char *new_string = NULL;
old_string = pdb_get_munged_dial(to);
mung = data_blob_const(from->parameters.array,
from->parameters.length);
new_string = (mung.length == 0) ?
NULL : base64_encode_data_blob(talloc_tos(), mung);
if (mung.length != 0) {
new_string = base64_encode_data_blob(talloc_tos(),
mung);
SMB_ASSERT(new_string != NULL);
}
DEBUG(10,("INFO_20 PARAMETERS: %s -> %s\n",
old_string, new_string));
if (STRING_CHANGED_NC(old_string,new_string)) {
@ -496,14 +501,17 @@ void copy_id21_to_sam_passwd(const char *log_prefix,
if ((from->fields_present & SAMR_FIELD_PARAMETERS) &&
(from->parameters.array)) {
char *newstr;
char *newstr = NULL;
DATA_BLOB mung;
old_string = pdb_get_munged_dial(to);
mung = data_blob_const(from->parameters.array,
from->parameters.length);
newstr = (mung.length == 0) ?
NULL : base64_encode_data_blob(talloc_tos(), mung);
if (mung.length != 0) {
newstr = base64_encode_data_blob(talloc_tos(), mung);
SMB_ASSERT(newstr != NULL);
}
DEBUG(10,("%s SAMR_FIELD_PARAMETERS: %s -> %s\n", l,
old_string, newstr));
if (STRING_CHANGED_NC(old_string,newstr)) {

View File

@ -1452,6 +1452,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
return;
} else {
base64_key = base64_encode_data_blob(state, session_key);
SMB_ASSERT(base64_key != NULL);
x_fprintf(x_stdout, "GK %s\n", base64_key);
talloc_free(base64_key);
}
@ -1481,6 +1482,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
if (out.length) {
out_base64 = base64_encode_data_blob(mem_ctx, out);
SMB_ASSERT(out_base64 != NULL);
} else {
out_base64 = NULL;
}

View File

@ -621,6 +621,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
return;
} else {
base64_key = base64_encode_data_blob(state, session_key);
SMB_ASSERT(base64_key != NULL);
mux_printf(mux_id, "GK %s\n", base64_key);
talloc_free(base64_key);
}
@ -648,6 +649,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
if (out.length) {
out_base64 = base64_encode_data_blob(mem_ctx, out);
SMB_ASSERT(out_base64 != NULL);
} else {
out_base64 = NULL;
}