Skip to content

Commit

Permalink
res: ucmd-module: more sanity checks for sid_ucmd_dev_alias_get_* params
Browse files Browse the repository at this point in the history
  • Loading branch information
prajnoha committed Jul 30, 2024
1 parent 1e6e1a1 commit 03cd8f7
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/resource/ubridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -3619,6 +3619,13 @@ const char **_do_sid_ucmd_dev_alias_get(sid_res_t *mod_res,

const char **sid_ucmd_dev_alias_get(sid_res_t *mod_res, struct sid_ucmd_ctx *ucmd_ctx, const char *alias_key, size_t *count)
{
if (!mod_res || !ucmd_ctx)
return NULL;

if (!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->block_mod_reg_res) &&
!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->type_mod_reg_res))
return NULL;

return _do_sid_ucmd_dev_alias_get(mod_res, ucmd_ctx, NULL, _owner_name(mod_res), alias_key, count);
}

Expand All @@ -3628,7 +3635,11 @@ const char **sid_ucmd_dev_alias_get_foreign_dev(sid_res_t *mod_res,
const char *alias_key,
size_t *count)
{
if (UTIL_STR_EMPTY(foreign_dev_id))
if (!mod_res || !ucmd_ctx || UTIL_STR_EMPTY(foreign_dev_id))
return NULL;

if (!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->block_mod_reg_res) &&
!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->type_mod_reg_res))
return NULL;

return _do_sid_ucmd_dev_alias_get(mod_res, ucmd_ctx, foreign_dev_id, _owner_name(mod_res), alias_key, count);
Expand All @@ -3640,7 +3651,11 @@ const char **sid_ucmd_dev_alias_get_foreign_mod(sid_res_t *mod_res,
const char *alias_key,
size_t *count)
{
if (UTIL_STR_EMPTY(foreign_mod_name))
if (!mod_res || !ucmd_ctx)
return NULL;

if (!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->block_mod_reg_res) &&
!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->type_mod_reg_res))
return NULL;

return _do_sid_ucmd_dev_alias_get(mod_res, ucmd_ctx, NULL, foreign_mod_name, alias_key, count);
Expand All @@ -3653,7 +3668,11 @@ const char **sid_ucmd_dev_alias_get_foreign_dev_mod(sid_res_t *mod_res
const char *alias_key,
size_t *count)
{
if (UTIL_STR_EMPTY(foreign_dev_id) || UTIL_STR_EMPTY(foreign_mod_name))
if (!mod_res || !ucmd_ctx || UTIL_STR_EMPTY(foreign_dev_id))
return NULL;

if (!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->block_mod_reg_res) &&
!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->type_mod_reg_res))
return NULL;

return _do_sid_ucmd_dev_alias_get(mod_res, ucmd_ctx, foreign_dev_id, foreign_mod_name, alias_key, count);
Expand Down

0 comments on commit 03cd8f7

Please sign in to comment.