Hello all
I'm evaluating OpenDBX for use in one of my projects, and found several errors:
- sqlite3 backend doesn't check that host parameter ends with /, and
simply appends database name to path, creating incorrect file name. I
attached simple patch to fix this - it checks, that path ends with /,
and if not, then adds it. The only improvement that should be made
there - add preprocessor condition to select / or \ depending on
platform used (unix or windows)
- second problem is more serious - it crash, when following
combination of commands was used:
1. create connection
2. bind
3. do select
4. retrieve results
5. call result.finish();
6. call connection.finish();
the problem is that if I call finish(), then unbind isn't called,
while finish will free database handle, that will be used in Conn
destructor, to perform unbind. I'm not sure how it's better to fix
this - one potential solution, is to use odbx_t** as parameter to
odbx_finish, so it will set handle to NULL, after it will freed.
Should I create bug for this issues?
--
With best wishes, Alex Ott
http://alexott.net/
Tiwtter: alexott_en (English), alexott (Russian)
Skype: alex.ott
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2e97f4b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,21 @@
+Makefile
+*~
+.deps/
+.libs/
+*.la
+*.lo
+*.o
+/config.h
+/config.log
+/config.status
+/lib/opendbx/api.h
+/libopendbx1.conf
+/libtool
+/po/Makefile.in
+/po/POTFILES
+/po/de.gmo
+/po/e...@quot.gmo
+/po/libopendbx1.pot
+/po/remove-potcdate.sed
+/stamp-h1
+/utils/po/POTFILES
diff --git a/backends/sqlite3/sqlite3_basic.c b/backends/sqlite3/sqlite3_basic.c
index 94474a0..7e29886 100644
--- a/backends/sqlite3/sqlite3_basic.c
+++ b/backends/sqlite3/sqlite3_basic.c
@@ -62,6 +62,8 @@ static const char* sqlite3_odbx_errmsg[] = {
* SQLite3 style
*/
+/* TODO: add platform-specific code for this */
+#define kPathSeparator '/'
/*
* SQLite3 doesn't connect to a database server. Instead it opens the database
@@ -71,6 +73,7 @@ static const char* sqlite3_odbx_errmsg[] = {
static int sqlite3_odbx_init( odbx_t* handle, const char* host, const char* port )
{
+ int hashTrailingSlash = 0;
DEBUGLOG( handle->log.write( &(handle->log), 1, "sqlite3_odbx_init() called" ); )
if( ( handle->aux = malloc( sizeof( struct sconn ) ) ) == NULL )
@@ -93,7 +96,10 @@ static int sqlite3_odbx_init( odbx_t* handle, const char* host, const char* port
if( host != NULL )
{
aux->pathlen = strlen( host ); /* host == directory */
-
+ if (host[aux->pathlen] == kPathSeparator) {
+ aux->pathlen++;
+ hashTrailingSlash = 1;
+ }
if( ( aux->path = malloc( aux->pathlen + 1 ) ) == NULL )
{
free( handle->aux );
@@ -101,8 +107,10 @@ static int sqlite3_odbx_init( odbx_t* handle, const char* host, const char* port
return -ODBX_ERR_NOMEM;
}
-
- snprintf( aux->path, aux->pathlen + 1, "%s", host );
+ if(hashTrailingSlash == 0)
+ snprintf( aux->path, aux->pathlen + 1, "%s%c", host, kPathSeparator );
+ else
+ snprintf( aux->path, aux->pathlen + 1, "%s", host );
}
return ODBX_ERR_SUCCESS;
------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn
about Cisco certifications, training, and career opportunities.
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
libopendbx-devel mailing list
libopendbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libopendbx-devel
http://www.linuxnetworks.de/doc/index.php/OpenDBX