Add get_by_desc ret val handling to get_fragment_size
As well as any other callers, libersurecode_get_fragment_size should handle the return value of liberasurecode_get_backend_instance_by_desc. Otherwise, get_by_desc can return NULL and it causes an invalid memory access in librerasurecode_get_fragment_size. Change-Id: I489f8b5d049610863b5e0b477b6ff70ead245b55
This commit is contained in:
parent
89807c5aac
commit
cb0daba975
|
@ -371,6 +371,7 @@ int liberasurecode_get_minimum_encode_size(int desc);
|
|||
*
|
||||
* @return fragment size - sizeof(fragment_header) + size
|
||||
* + frag_backend_metadata_size
|
||||
* if an error, return value will be negative
|
||||
*/
|
||||
int liberasurecode_get_fragment_size(int desc, int data_len);
|
||||
|
||||
|
|
|
@ -1221,6 +1221,8 @@ int liberasurecode_get_fragment_size(int desc, int data_len)
|
|||
{
|
||||
ec_backend_t instance = liberasurecode_backend_instance_get_by_desc(desc);
|
||||
// TODO: Create a common function to calculate fragment size also for preprocessing
|
||||
if (NULL == instance)
|
||||
return -EBACKENDNOTAVAIL;
|
||||
int aligned_data_len = get_aligned_data_size(instance, data_len);
|
||||
int size = (aligned_data_len / instance->args.uargs.k) + instance->common.backend_metadata_size;
|
||||
|
||||
|
|
Loading…
Reference in New Issue