From 3ac497c6ff00aa4546e09324976b27b9caf66a16 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 12 Oct 2020 13:08:28 +1000 Subject: [PATCH 1/3] Fix crash when a missing file is accessed via ODBC --- src/sql/mdbsql.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/sql/mdbsql.c b/src/sql/mdbsql.c index 9acaeab..7f5dcf4 100644 --- a/src/sql/mdbsql.c +++ b/src/sql/mdbsql.c @@ -161,12 +161,26 @@ MdbHandle *mdb_sql_open(MdbSQL *sql, char *db_name) #ifdef HAVE_WORDEXP wordexp_t words; + int need_free_words = 0; - if (wordexp(db_name, &words, 0)==0) { - if (words.we_wordc>0) - db_namep = words.we_wordv[0]; + switch (wordexp(db_name, &words, 0)) + { + case 0: + if (words.we_wordc>0) + { + db_namep = words.we_wordv[0]; + } + need_free_words = 1; + break; + case WRDE_NOSPACE: + // If the error was WRDE_NOSPACE, then perhaps part of the result was allocated. + need_free_words = 1; + break; + default: + // Some other error + need_free_words = 0; + break; } - #endif sql->mdb = mdb_open(db_namep, MDB_NOFLAGS); @@ -180,7 +194,10 @@ MdbHandle *mdb_sql_open(MdbSQL *sql, char *db_name) } #ifdef HAVE_WORDEXP - wordfree(&words); + if ( need_free_words ) + { + wordfree(&words); + } #endif return sql->mdb; From 6a4102053804f9b2acc80fb6b885851649ff1830 Mon Sep 17 00:00:00 2001 From: nirgal Date: Sun, 18 Oct 2020 08:59:36 +0000 Subject: [PATCH 2/3] Spelling typo --- src/util/mdb-queries.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/mdb-queries.c b/src/util/mdb-queries.c index 2690c02..ab8d7bc 100644 --- a/src/util/mdb-queries.c +++ b/src/util/mdb-queries.c @@ -89,7 +89,7 @@ int main (int argc, char **argv) { fprintf (stderr, "Usage: %s [options] \n",argv[0]); fprintf (stderr, "where options are:\n"); fprintf (stderr, " -L\t\t\tList queries in the database (default if no query name is passed)\n"); - fprintf (stderr, " -1\t\t\tUse newline as the delimiter (used in conjuction with listing)\n"); + fprintf (stderr, " -1\t\t\tUse newline as the delimiter (used in conjunction with listing)\n"); fprintf (stderr, " -d \tSpecify delimiter to use\n"); exit (1); } From 73e0de306db9ee8ddc15e752e52779c22115fc25 Mon Sep 17 00:00:00 2001 From: nirgal Date: Sun, 18 Oct 2020 09:13:14 +0000 Subject: [PATCH 3/3] Add back missing coma --- doc/mdb-export.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/mdb-export.txt b/doc/mdb-export.txt index dd5de0c..b4f63ad 100644 --- a/doc/mdb-export.txt +++ b/doc/mdb-export.txt @@ -20,7 +20,7 @@ OPTIONS -q, --quote char Use to wrap text-like fields. Default is " (double quote). -X, --escape char Use to escape quoted characters within a field. Default is doubling. -N, --namespace prefix Prefix identifiers with prefix. - -b --bin strip|raw|octal|hex Binary export mode: strip binaries, export as-is, output \ooo style octal data or output \xx style hexadecimal data. + -b, --bin strip|raw|octal|hex Binary export mode: strip binaries, export as-is, output \ooo style octal data or output \xx style hexadecimal data. NOTES