Commit 5219c5a3 authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

lsm: don't crash with "undefined" profile in images

If the profile is "undefined" render_lsm_profile doesn't render anything,
since there is no need to set a profile. We shouldn't crash in this case.

We never hit this bug because we are careful not to put an "undefined"
profile into the images. But, if someone else edits the images, we
shouldn't crash on restore because of that.

Closes #110

Reported-by: Coverity
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 7c4a37f5
......@@ -2830,13 +2830,14 @@ rst_prep_creds_args(CredsEntry *ce, unsigned long *prev_pos)
if (validate_lsm(profile) < 0)
return ERR_PTR(-EINVAL);
if (profile) {
if (profile && render_lsm_profile(profile, &rendered)) {
return ERR_PTR(-EINVAL);
}
if (rendered) {
size_t lsm_profile_len;
char *lsm_profile;
if (render_lsm_profile(profile, &rendered))
return ERR_PTR(-EINVAL);
args->mem_lsm_profile_pos = rst_mem_cpos(RM_PRIVATE);
lsm_profile_len = strlen(rendered);
lsm_profile = rst_mem_alloc(lsm_profile_len + 1, RM_PRIVATE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment