[PATCH v1] mkfs.ubifs: Fix mkfs.ubifs failure with option selinux

Zhihao Cheng chengzhihao1 at huawei.com
Fri May 26 04:21:25 PDT 2023


在 2023/5/26 16:47, Zijun Hu 写道:
> Below failure happens when mkfs.ubifs --selinux=FILE ...
> "Error: bad file context FILE 1"
> "No such file or directory (error 2)"
> 
> It is fixed by this change.
> 
> Signed-off-by: Zijun Hu <quic_zijuhu at quicinc.com>
> ---
>   ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
> index 8211ada..15e6bdc 100644
> --- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
> +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
> @@ -733,6 +733,7 @@ static int get_options(int argc, char**argv)
>   			if (!context)
>   				return err_msg("xmalloc failed\n");
>   			memcpy(context, optarg, context_len);
> +			context[context_len] = '\0';

Makes sense, 'context' is allocated without initialization, it may be 
terminated with non '\0'.

Reviewed-by: Zhihao Cheng <chengzhihao1 at huawei.com>

>   
>   			/* Make sure root directory exists */
>   			if (stat(context, &context_st))
> 




More information about the linux-mtd mailing list