mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
lib: Fix error path memleaks in read_ea_list_entry()
Don't leak the result on error Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Wed Dec 18 09:30:33 UTC 2024 on atb-devel-224
This commit is contained in:
parent
dc84e98ed5
commit
ff4c70e03a
@ -33,11 +33,11 @@ struct ea_list *read_ea_list_entry(TALLOC_CTX *ctx, const char *pdata, size_t da
|
|||||||
size_t converted_size;
|
size_t converted_size;
|
||||||
|
|
||||||
if (!eal) {
|
if (!eal) {
|
||||||
return NULL;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data_size < 6) {
|
if (data_size < 6) {
|
||||||
return NULL;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
eal->ea.flags = CVAL(pdata,0);
|
eal->ea.flags = CVAL(pdata,0);
|
||||||
@ -45,23 +45,23 @@ struct ea_list *read_ea_list_entry(TALLOC_CTX *ctx, const char *pdata, size_t da
|
|||||||
val_len = SVAL(pdata,2);
|
val_len = SVAL(pdata,2);
|
||||||
|
|
||||||
if (4 + namelen + 1 + val_len > data_size) {
|
if (4 + namelen + 1 + val_len > data_size) {
|
||||||
return NULL;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ensure the name is null terminated. */
|
/* Ensure the name is null terminated. */
|
||||||
if (pdata[namelen + 4] != '\0') {
|
if (pdata[namelen + 4] != '\0') {
|
||||||
return NULL;
|
goto fail;
|
||||||
}
|
}
|
||||||
if (!pull_ascii_talloc(ctx, &eal->ea.name, pdata + 4, &converted_size)) {
|
if (!pull_ascii_talloc(ctx, &eal->ea.name, pdata + 4, &converted_size)) {
|
||||||
DBG_ERR("pull_ascii_talloc failed: %s\n", strerror(errno));
|
DBG_ERR("pull_ascii_talloc failed: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
if (!eal->ea.name) {
|
if (!eal->ea.name) {
|
||||||
return NULL;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
eal->ea.value = data_blob_talloc(eal, NULL, (size_t)val_len + 1);
|
eal->ea.value = data_blob_talloc(eal, NULL, (size_t)val_len + 1);
|
||||||
if (!eal->ea.value.data) {
|
if (!eal->ea.value.data) {
|
||||||
return NULL;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(eal->ea.value.data, pdata + 4 + namelen + 1, val_len);
|
memcpy(eal->ea.value.data, pdata + 4 + namelen + 1, val_len);
|
||||||
@ -79,6 +79,9 @@ struct ea_list *read_ea_list_entry(TALLOC_CTX *ctx, const char *pdata, size_t da
|
|||||||
dump_data(10, eal->ea.value.data, eal->ea.value.length);
|
dump_data(10, eal->ea.value.data, eal->ea.value.length);
|
||||||
|
|
||||||
return eal;
|
return eal;
|
||||||
|
fail:
|
||||||
|
TALLOC_FREE(eal);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
Loading…
Reference in New Issue
Block a user