summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichal Zidek <mzidek@redhat.com>2012-11-27 13:15:41 +0100
committerJakub Hrozek <jhrozek@redhat.com>2012-11-28 13:47:43 +0100
commitae86a405b8f5b8be3d63648555c6c1430794ac71 (patch)
tree72a0d3e197d6ae3b4f056bd36365c071b235bbe3 /src
parentdf24b52d8b809ab47f89221bed247e13281ca20a (diff)
downloadsssd-ae86a405b8f5b8be3d63648555c6c1430794ac71.tar.gz
sssd-ae86a405b8f5b8be3d63648555c6c1430794ac71.tar.xz
sssd-ae86a405b8f5b8be3d63648555c6c1430794ac71.zip
Null pointer dereferenced.
https://fedorahosted.org/sssd/ticket/1674
Diffstat (limited to 'src')
-rw-r--r--src/db/sysdb.c196
1 files changed, 100 insertions, 96 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index e82c18495..a49fa50d7 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -1047,130 +1047,134 @@ int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx,
if (res->count == 1) {
el = ldb_msg_find_element(res->msgs[0], "version");
- if (el) {
- if (el->num_values != 1) {
- ret = EINVAL;
- goto done;
- }
- version = talloc_strndup(tmp_ctx,
- (char *)(el->values[0].data),
- el->values[0].length);
- if (!version) {
- ret = ENOMEM;
- goto done;
- }
+ if (!el) {
+ ret = EIO;
+ goto done;
+ }
- if (strcmp(version, SYSDB_VERSION) == 0) {
- /* all fine, return */
- ret = EOK;
- goto done;
- }
+ if (el->num_values != 1) {
+ ret = EINVAL;
+ goto done;
+ }
+ version = talloc_strndup(tmp_ctx,
+ (char *)(el->values[0].data),
+ el->values[0].length);
+ if (!version) {
+ ret = ENOMEM;
+ goto done;
+ }
- if (!allow_upgrade) {
- DEBUG(0, ("Wrong DB version (got %s expected %s)\n",
- version, SYSDB_VERSION));
- ret = sysdb_version_check(SYSDB_VERSION, version);
- goto done;
- }
+ if (strcmp(version, SYSDB_VERSION) == 0) {
+ /* all fine, return */
+ ret = EOK;
+ goto done;
+ }
- DEBUG(4, ("Upgrading DB [%s] from version: %s\n",
- domain->name, version));
+ if (!allow_upgrade) {
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ ("Wrong DB version (got %s expected %s)\n",
+ version, SYSDB_VERSION));
+ ret = sysdb_version_check(SYSDB_VERSION, version);
+ goto done;
+ }
- if (strcmp(version, SYSDB_VERSION_0_3) == 0) {
- ret = sysdb_upgrade_03(sysdb, &version);
- if (ret != EOK) {
- goto done;
- }
+ DEBUG(SSSDBG_CONF_SETTINGS, ("Upgrading DB [%s] from version: %s\n",
+ domain->name, version));
+
+ if (strcmp(version, SYSDB_VERSION_0_3) == 0) {
+ ret = sysdb_upgrade_03(sysdb, &version);
+ if (ret != EOK) {
+ goto done;
}
+ }
- if (strcmp(version, SYSDB_VERSION_0_4) == 0) {
- ret = sysdb_upgrade_04(sysdb, &version);
- if (ret != EOK) {
- goto done;
- }
+ if (strcmp(version, SYSDB_VERSION_0_4) == 0) {
+ ret = sysdb_upgrade_04(sysdb, &version);
+ if (ret != EOK) {
+ goto done;
}
+ }
- if (strcmp(version, SYSDB_VERSION_0_5) == 0) {
- ret = sysdb_upgrade_05(sysdb, &version);
- if (ret != EOK) {
- goto done;
- }
+ if (strcmp(version, SYSDB_VERSION_0_5) == 0) {
+ ret = sysdb_upgrade_05(sysdb, &version);
+ if (ret != EOK) {
+ goto done;
}
+ }
- if (strcmp(version, SYSDB_VERSION_0_6) == 0) {
- ret = sysdb_upgrade_06(sysdb, &version);
- if (ret != EOK) {
- goto done;
- }
+ if (strcmp(version, SYSDB_VERSION_0_6) == 0) {
+ ret = sysdb_upgrade_06(sysdb, &version);
+ if (ret != EOK) {
+ goto done;
}
+ }
- if (strcmp(version, SYSDB_VERSION_0_7) == 0) {
- ret = sysdb_upgrade_07(sysdb, &version);
- if (ret != EOK) {
- goto done;
- }
+ if (strcmp(version, SYSDB_VERSION_0_7) == 0) {
+ ret = sysdb_upgrade_07(sysdb, &version);
+ if (ret != EOK) {
+ goto done;
}
+ }
- if (strcmp(version, SYSDB_VERSION_0_8) == 0) {
- ret = sysdb_upgrade_08(sysdb, &version);
- if (ret != EOK) {
- goto done;
- }
+ if (strcmp(version, SYSDB_VERSION_0_8) == 0) {
+ ret = sysdb_upgrade_08(sysdb, &version);
+ if (ret != EOK) {
+ goto done;
}
+ }
- if (strcmp(version, SYSDB_VERSION_0_9) == 0) {
- ret = sysdb_upgrade_09(sysdb, &version);
- if (ret != EOK) {
- goto done;
- }
+ if (strcmp(version, SYSDB_VERSION_0_9) == 0) {
+ ret = sysdb_upgrade_09(sysdb, &version);
+ if (ret != EOK) {
+ goto done;
}
+ }
- if (strcmp(version, SYSDB_VERSION_0_10) == 0) {
- ret = sysdb_upgrade_10(sysdb, &version);
- if (ret != EOK) {
- goto done;
- }
+ if (strcmp(version, SYSDB_VERSION_0_10) == 0) {
+ ret = sysdb_upgrade_10(sysdb, &version);
+ if (ret != EOK) {
+ goto done;
}
+ }
- if (strcmp(version, SYSDB_VERSION_0_11) == 0) {
- ret = sysdb_upgrade_11(sysdb, &version);
- if (ret != EOK) {
- goto done;
- }
+ if (strcmp(version, SYSDB_VERSION_0_11) == 0) {
+ ret = sysdb_upgrade_11(sysdb, &version);
+ if (ret != EOK) {
+ goto done;
}
+ }
- if (strcmp(version, SYSDB_VERSION_0_12) == 0) {
- ret = sysdb_upgrade_12(sysdb, &version);
- if (ret != EOK) {
- goto done;
- }
+ if (strcmp(version, SYSDB_VERSION_0_12) == 0) {
+ ret = sysdb_upgrade_12(sysdb, &version);
+ if (ret != EOK) {
+ goto done;
}
+ }
- if (strcmp(version, SYSDB_VERSION_0_13) == 0) {
- ret = sysdb_upgrade_13(sysdb, &version);
- if (ret != EOK) {
- goto done;
- }
+ if (strcmp(version, SYSDB_VERSION_0_13) == 0) {
+ ret = sysdb_upgrade_13(sysdb, &version);
+ if (ret != EOK) {
+ goto done;
}
+ }
- /* The version should now match SYSDB_VERSION.
- * If not, it means we didn't match any of the
- * known older versions. The DB might be
- * corrupt or generated by a newer version of
- * SSSD.
+ /* The version should now match SYSDB_VERSION.
+ * If not, it means we didn't match any of the
+ * known older versions. The DB might be
+ * corrupt or generated by a newer version of
+ * SSSD.
+ */
+ if (strcmp(version, SYSDB_VERSION) == 0) {
+ /* The cache has been upgraded.
+ * We need to reopen the LDB to ensure that
+ * any changes made above take effect.
*/
- if (strcmp(version, SYSDB_VERSION) == 0) {
- /* The cache has been upgraded.
- * We need to reopen the LDB to ensure that
- * any changes made above take effect.
- */
- talloc_zfree(sysdb->ldb);
- ret = sysdb_ldb_connect(sysdb, sysdb->ldb_file, &sysdb->ldb);
- if (ret != EOK) {
- DEBUG(1, ("sysdb_ldb_connect failed.\n"));
- }
- goto done;
+ talloc_zfree(sysdb->ldb);
+ ret = sysdb_ldb_connect(sysdb, sysdb->ldb_file, &sysdb->ldb);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_CRIT_FAILURE, ("sysdb_ldb_connect failed.\n"));
}
+ goto done;
}
DEBUG(0,("Unknown DB version [%s], expected [%s] for domain %s!\n",