stat: fix printing selinux context and null-dereference
busybox stat tries to always print the selinux context, even if it is not requested which leads to a segmentation fault due to dereferencing a null-pointer. This also changes the format-string used to print the context to so it actually produces useful output. Signed-off-by: Michael Gernoth <michael@gernoth.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
9d7cbdeee3
commit
1b487ea8a6
@ -655,7 +655,7 @@ static bool do_stat(const char *filename, const char *format)
|
|||||||
);
|
);
|
||||||
# if ENABLE_SELINUX
|
# if ENABLE_SELINUX
|
||||||
if (option_mask32 & OPT_SELINUX)
|
if (option_mask32 & OPT_SELINUX)
|
||||||
printf(" %lc\n", *scontext);
|
printf(" %s\n", scontext);
|
||||||
else
|
else
|
||||||
bb_putchar('\n');
|
bb_putchar('\n');
|
||||||
# endif
|
# endif
|
||||||
@ -700,7 +700,8 @@ static bool do_stat(const char *filename, const char *format)
|
|||||||
(unsigned long) statbuf.st_gid,
|
(unsigned long) statbuf.st_gid,
|
||||||
(gw_ent != NULL) ? gw_ent->gr_name : "UNKNOWN");
|
(gw_ent != NULL) ? gw_ent->gr_name : "UNKNOWN");
|
||||||
# if ENABLE_SELINUX
|
# if ENABLE_SELINUX
|
||||||
printf(" S_Context: %lc\n", *scontext);
|
if (option_mask32 & OPT_SELINUX)
|
||||||
|
printf(" S_Context: %s\n", scontext);
|
||||||
# endif
|
# endif
|
||||||
printf("Access: %s\n", human_time(statbuf.st_atime));
|
printf("Access: %s\n", human_time(statbuf.st_atime));
|
||||||
printf("Modify: %s\n", human_time(statbuf.st_mtime));
|
printf("Modify: %s\n", human_time(statbuf.st_mtime));
|
||||||
|
Loading…
Reference in New Issue
Block a user