diff options
author | Michal Zidek <mzidek@redhat.com> | 2012-11-27 13:15:41 +0100 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2012-11-28 14:45:56 +0100 |
commit | 343fa08af09beaad71980d7a382036dd9a1dddde (patch) | |
tree | dbc69199612789e5e7026dc55f00bda95e5be993 | |
parent | 3f964af2d45b85c8c7461f5227b343340ab06b06 (diff) | |
download | sssd-343fa08af09beaad71980d7a382036dd9a1dddde.tar.gz sssd-343fa08af09beaad71980d7a382036dd9a1dddde.tar.xz sssd-343fa08af09beaad71980d7a382036dd9a1dddde.zip |
Null pointer dereferenced.
https://fedorahosted.org/sssd/ticket/1674
-rw-r--r-- | src/db/sysdb.c | 196 |
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", |