aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Gernoth <michael@gernoth.net>2014-06-27 14:08:29 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2014-06-27 14:08:29 +0200
commit1b487ea8a69ac90b530e9ccd161a5b1b21e604c7 (patch)
tree78d79dac1e614af04d26d37a72237d0371cee458
parent9d7cbdeee3545d36db201a2d822cd2bd10074add (diff)
downloadbusybox-w32-1b487ea8a69ac90b530e9ccd161a5b1b21e604c7.tar.gz
busybox-w32-1b487ea8a69ac90b530e9ccd161a5b1b21e604c7.tar.bz2
busybox-w32-1b487ea8a69ac90b530e9ccd161a5b1b21e604c7.zip
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>
-rw-r--r--coreutils/stat.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/coreutils/stat.c b/coreutils/stat.c
index dc9d81c35..769fac078 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -655,7 +655,7 @@ static bool do_stat(const char *filename, const char *format)
655 ); 655 );
656# if ENABLE_SELINUX 656# if ENABLE_SELINUX
657 if (option_mask32 & OPT_SELINUX) 657 if (option_mask32 & OPT_SELINUX)
658 printf(" %lc\n", *scontext); 658 printf(" %s\n", scontext);
659 else 659 else
660 bb_putchar('\n'); 660 bb_putchar('\n');
661# endif 661# endif
@@ -700,7 +700,8 @@ static bool do_stat(const char *filename, const char *format)
700 (unsigned long) statbuf.st_gid, 700 (unsigned long) statbuf.st_gid,
701 (gw_ent != NULL) ? gw_ent->gr_name : "UNKNOWN"); 701 (gw_ent != NULL) ? gw_ent->gr_name : "UNKNOWN");
702# if ENABLE_SELINUX 702# if ENABLE_SELINUX
703 printf(" S_Context: %lc\n", *scontext); 703 if (option_mask32 & OPT_SELINUX)
704 printf(" S_Context: %s\n", scontext);
704# endif 705# endif
705 printf("Access: %s\n", human_time(statbuf.st_atime)); 706 printf("Access: %s\n", human_time(statbuf.st_atime));
706 printf("Modify: %s\n", human_time(statbuf.st_mtime)); 707 printf("Modify: %s\n", human_time(statbuf.st_mtime));