More robust query result access if columns are missing.

This commit is contained in:
Klaas Freitag 2012-08-26 20:07:36 +02:00
parent 9897335006
commit 3b369c8b03

View file

@ -396,9 +396,8 @@ csync_file_stat_t *csync_statedb_get_stat_by_hash(CSYNC *ctx, uint64_t phash) {
return NULL; return NULL;
} }
if (result->count <= 6) { if (result->count < 10) {
c_strlist_destroy(result); CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "WRN: Amount of result columns wrong, db version mismatch!");
return NULL;
} }
/* phash, pathlen, path, inode, uid, gid, mode, modtime */ /* phash, pathlen, path, inode, uid, gid, mode, modtime */
len = strlen(result->vector[2]); len = strlen(result->vector[2]);
@ -428,9 +427,14 @@ csync_file_stat_t *csync_statedb_get_stat_by_hash(CSYNC *ctx, uint64_t phash) {
st->gid = atoi(result->vector[5]); st->gid = atoi(result->vector[5]);
st->mode = atoi(result->vector[6]); st->mode = atoi(result->vector[6]);
st->modtime = strtoul(result->vector[7], NULL, 10); st->modtime = strtoul(result->vector[7], NULL, 10);
if(result->count > 8 && result->vector[8]) {
st->type = atoi(result->vector[8]); st->type = atoi(result->vector[8]);
if( result->vector[9]) }
if(result->count > 9 && result->vector[9]) {
st->md5 = c_strdup( result->vector[9] ); st->md5 = c_strdup( result->vector[9] );
}
c_strlist_destroy(result); c_strlist_destroy(result);
return st; return st;