Message ID | 1685090853-25855-1-git-send-email-quic_zijuhu@quicinc.com |
---|---|
State | New |
Delegated to: | Richard Weinberger |
Headers | show |
Series | [v1] mkfs.ubifs: Fix mkfs.ubifs failure with option selinux | expand |
在 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@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@huawei.com> > > /* Make sure root directory exists */ > if (stat(context, &context_st)) >
Applied to mtd-utils.git master. Thanks, David
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'; /* Make sure root directory exists */ if (stat(context, &context_st))
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@quicinc.com> --- ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 1 + 1 file changed, 1 insertion(+)