From 442a9b4f3c37c26248496031ec28b753cbaf893e Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann?= Date: Thu, 9 Nov 2006 21:02:31 +0000 Subject: [PATCH] Die immediately if the output file is a directory. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Thu Nov 9 16:01:47 2006 Søren Sandmann * sysprof-text.c (main): Die immediately if the output file is a directory. * autogen.sh (DIE): Also work when automake-1.9 is installed. --- ChangeLog | 7 +++++++ autogen.sh | 12 +++++++----- binfile.c | 2 ++ sysprof-text.c | 15 +++++++++++++++ 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2b7515c..72bd1af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Thu Nov 9 16:01:47 2006 Søren Sandmann + + * sysprof-text.c (main): Die immediately if the output file is a + directory. + + * autogen.sh (DIE): Also work when automake-1.9 is installed. + 2006-11-02 Soren Sandmann Valgrind: diff --git a/autogen.sh b/autogen.sh index 813102c..7a7d410 100755 --- a/autogen.sh +++ b/autogen.sh @@ -24,11 +24,13 @@ if automake-1.7 --version < /dev/null > /dev/null 2>&1 ; then AUTOMAKE=automake-1.7 ACLOCAL=aclocal-1.7 else - echo - echo "You must have automake 1.7.x installed to compile $PROJECT." - echo "Install the appropriate package for your distribution," - echo "or get the source tarball at http://ftp.gnu.org/gnu/automake/" - DIE=1 + if automake-1.9 --version < /dev/null > /dev/null 2>&1 ; then + AUTOMAKE=automake-1.9 + ACLOCAL=aclocal-1.9 + else + AUTOMAKE=automake + ACLOCAL=aclocal + fi fi if test "$DIE" -eq 1; then diff --git a/binfile.c b/binfile.c index 325e2ec..ca5ae93 100644 --- a/binfile.c +++ b/binfile.c @@ -231,6 +231,8 @@ bin_file_new (const char *filename) else { bf->elf = elf_parser_new (filename, NULL); + if (!bf->elf) + g_print ("Could not parse file %s\n", bf->elf); } /* We need the text offset of the actual binary, not the diff --git a/sysprof-text.c b/sysprof-text.c index 2d16818..e142169 100644 --- a/sysprof-text.c +++ b/sysprof-text.c @@ -86,6 +86,14 @@ usage_msg (const char *name) name); } +static gboolean +file_exists_and_is_dir (const char *name) +{ + return + g_file_test (name, G_FILE_TEST_EXISTS) && + g_file_test (name, G_FILE_TEST_IS_DIR); +} + static void die (const char *err_msg) { @@ -119,6 +127,13 @@ main (int argc, if (!signal_set_handler (SIGINT, signal_handler, app, &err)) die (err->message); + + if (file_exists_and_is_dir (app->outfile)) + { + char *msg = g_strdup_printf ("Can't write to %s: is a directory\n", + app->outfile); + die (msg); + } g_main_loop_run (app->main_loop); -- 2.7.4