From: Kern Sibbald Date: Sat, 30 Jan 2010 07:48:11 +0000 (+0100) Subject: Fix seg fault in SQlite driver X-Git-Tag: Release-7.0.0~2290 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a94fde1ec3ad3d24fa562364fa692315797f200d;p=bacula%2Fbacula Fix seg fault in SQlite driver --- diff --git a/bacula/src/cats/sqlite.c b/bacula/src/cats/sqlite.c index 1672f07502..93d4196ae3 100644 --- a/bacula/src/cats/sqlite.c +++ b/bacula/src/cats/sqlite.c @@ -448,6 +448,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++;