From: Kern Sibbald Date: Sat, 30 Jan 2010 07:48:11 +0000 (+0100) Subject: Fix seg fault in SQlite driver X-Git-Tag: Release-5.0.1~144 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=af57cd04d48e9eb3225e017269b1a323ea83cdeb;p=bacula%2Fbacula Fix seg fault in SQlite driver --- diff --git a/bacula/src/cats/sqlite.c b/bacula/src/cats/sqlite.c index f98539ed38..d18b24e891 100644 --- a/bacula/src/cats/sqlite.c +++ b/bacula/src/cats/sqlite.c @@ -446,6 +446,13 @@ void my_sqlite_field_seek(B_DB *mdb, int field) mdb->fields = (SQL_FIELD **)malloc(sizeof(SQL_FIELD) * mdb->ncolumn); for (i=0; i < sql_num_fields(mdb); i++) { mdb->fields[i] = (SQL_FIELD *)malloc(sizeof(SQL_FIELD)); + if (mdb->result[i] == NULL) { + mdb->fields_defined = false; + free(mdb->fields); + mdb->fields = NULL; + mdb->field = 0; + return; + } mdb->fields[i]->name = mdb->result[i]; mdb->fields[i]->length = cstrlen(mdb->fields[i]->name); mdb->fields[i]->max_length = mdb->fields[i]->length; diff --git a/bacula/src/lib/bsys.c b/bacula/src/lib/bsys.c index fe86199db3..f5d7bc6a7a 100644 --- a/bacula/src/lib/bsys.c +++ b/bacula/src/lib/bsys.c @@ -160,6 +160,9 @@ int cstrlen(const char *str) { uint8_t *p = (uint8_t *)str; int len = 0; + if (str == NULL) { + return 0; + } while (*p) { if ((*p & 0xC0) != 0xC0) { p++;