From c2eee93088aad4876c2f25fcb78d67ad18ffa425 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 15 Feb 2009 01:08:00 -0500 Subject: libsandbox: calculate longest symbol name dynamically The longest wrapped symbol name has hit the hard limit of 10 chars, so rather than manually bump it up, calculate it on the fly with the awk scripts. Signed-off-by: Mike Frysinger --- libsandbox/Makefile.am | 2 +- libsandbox/libsandbox.c | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'libsandbox') diff --git a/libsandbox/Makefile.am b/libsandbox/Makefile.am index e38cc29..97d8864 100644 --- a/libsandbox/Makefile.am +++ b/libsandbox/Makefile.am @@ -53,7 +53,7 @@ symbols.h: $(SYMBOLS_FILE) $(SYMBOLS_WRAPPERS) $(GEN_HEADER_SCRIPT) SB_NR_FILE = $(srcdir)/sb_nr.h.in sb_nr.h: symbols.h $(SB_NR_FILE) - $(EGREP) -h '^\#define SB_NR_' $^ > $@ + $(EGREP) -h '^\#define SB_' $^ > $@ EXTRA_DIST = $(SYMBOLS_FILE) $(SYMBOLS_WRAPPERS) $(SB_NR_FILE) diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c index ffda996..758b9e5 100644 --- a/libsandbox/libsandbox.c +++ b/libsandbox/libsandbox.c @@ -744,17 +744,14 @@ static int check_syscall(sbcontext_t *sbcontext, int sb_nr, const char *func, co result = check_access(sbcontext, sb_nr, func, absolute_path, resolved_path); - if (1 == verbose) { - if ((0 == result) && (1 == sbcontext->show_access_violation)) { - SB_EERROR("ACCESS DENIED", " %s:%*s%s\n", - func, (int)(10 - strlen(func)), "", absolute_path); - } else if ((1 == debug) && (1 == sbcontext->show_access_violation)) { - SB_EINFO("ACCESS ALLOWED", " %s:%*s%s\n", - func, (int)(10 - strlen(func)), "", absolute_path); - } else if ((1 == debug) && (0 == sbcontext->show_access_violation)) { - SB_EWARN("ACCESS PREDICTED", " %s:%*s%s\n", - func, (int)(10 - strlen(func)), "", absolute_path); - } + if (verbose) { + int sym_len = SB_MAX_STRING_LEN + 1 - strlen(func); + if (!result && sbcontext->show_access_violation) + SB_EERROR("ACCESS DENIED", " %s:%*s%s\n", func, sym_len, "", absolute_path); + else if (debug && sbcontext->show_access_violation) + SB_EINFO("ACCESS ALLOWED", " %s:%*s%s\n", func, sym_len, "", absolute_path); + else if (debug && !sbcontext->show_access_violation) + SB_EWARN("ACCESS PREDICTED", " %s:%*s%s\n", func, sym_len, "", absolute_path); } if ((0 == result) && (1 == sbcontext->show_access_violation)) -- cgit v1.2.3-65-gdbad