Misc fixes (coverity)
This commit is contained in:
@@ -108,11 +108,9 @@ hdb_get_dbinfo(krb5_context context, struct hdb_dbinfo **dbp)
|
||||
NULL);
|
||||
if (db_binding) {
|
||||
|
||||
ret = get_dbinfo(context, db_binding, "default", &di);
|
||||
if (ret == 0 && di) {
|
||||
databases = di;
|
||||
dt = &di->next;
|
||||
}
|
||||
ret = get_dbinfo(context, db_binding, "default", &databases);
|
||||
if (ret == 0 && databases != NULL)
|
||||
dt = &databases->next;
|
||||
|
||||
for ( ; db_binding != NULL; db_binding = db_binding->next) {
|
||||
|
||||
@@ -129,27 +127,28 @@ hdb_get_dbinfo(krb5_context context, struct hdb_dbinfo **dbp)
|
||||
|
||||
if (dt)
|
||||
*dt = di;
|
||||
else
|
||||
else {
|
||||
hdb_free_dbinfo(context, &databases);
|
||||
databases = di;
|
||||
}
|
||||
dt = &di->next;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(databases == NULL) {
|
||||
if (databases == NULL) {
|
||||
/* if there are none specified, create one and use defaults */
|
||||
di = calloc(1, sizeof(*di));
|
||||
databases = di;
|
||||
di->label = strdup("default");
|
||||
databases = calloc(1, sizeof(*databases));
|
||||
databases->label = strdup("default");
|
||||
}
|
||||
|
||||
for(di = databases; di; di = di->next) {
|
||||
if(di->dbname == NULL) {
|
||||
for (di = databases; di; di = di->next) {
|
||||
if (di->dbname == NULL) {
|
||||
di->dbname = strdup(default_dbname);
|
||||
if (di->mkey_file == NULL)
|
||||
di->mkey_file = strdup(default_mkey);
|
||||
}
|
||||
if(di->mkey_file == NULL) {
|
||||
if (di->mkey_file == NULL) {
|
||||
p = strrchr(di->dbname, '.');
|
||||
if(p == NULL || strchr(p, '/') != NULL)
|
||||
/* final pathname component does not contain a . */
|
||||
@@ -159,8 +158,10 @@ hdb_get_dbinfo(krb5_context context, struct hdb_dbinfo **dbp)
|
||||
.mkey */
|
||||
ret = asprintf(&di->mkey_file, "%.*s.mkey",
|
||||
(int)(p - di->dbname), di->dbname);
|
||||
if (ret == -1)
|
||||
if (ret == -1) {
|
||||
hdb_free_dbinfo(context, &databases);
|
||||
return ENOMEM;
|
||||
}
|
||||
}
|
||||
if(di->acl_file == NULL)
|
||||
di->acl_file = strdup(default_acl);
|
||||
|
@@ -2044,8 +2044,7 @@ hdb_ldapi_create(krb5_context context, HDB ** db, const char *arg)
|
||||
krb5_error_code ret;
|
||||
char *search_base, *p;
|
||||
|
||||
asprintf(&p, "ldapi:%s", arg);
|
||||
if (p == NULL) {
|
||||
if (asprintf(&p, "ldapi:%s", arg) == -1 || p == NULL) {
|
||||
*db = NULL;
|
||||
krb5_set_error_message(context, ENOMEM, "out of memory");
|
||||
return ENOMEM;
|
||||
|
@@ -1212,7 +1212,7 @@ getdata(char **p, unsigned char *buf, size_t len, const char *what)
|
||||
}
|
||||
i = 0;
|
||||
while (*q && i < len) {
|
||||
if(sscanf(q, "%02x", &v) != 1)
|
||||
if (sscanf(q, "%02x", &v) != 1)
|
||||
break;
|
||||
buf[i++] = v;
|
||||
q += 2;
|
||||
@@ -1229,7 +1229,8 @@ getint(char **p, const char *what)
|
||||
warnx("Failed to find a signed integer (%s) in dump", what);
|
||||
return -1;
|
||||
}
|
||||
sscanf(q, "%d", &val);
|
||||
if (sscanf(q, "%d", &val) != 1)
|
||||
return -1;
|
||||
return val;
|
||||
}
|
||||
|
||||
@@ -1242,7 +1243,8 @@ getuint(char **p, const char *what)
|
||||
warnx("Failed to find an unsigned integer (%s) in dump", what);
|
||||
return 0;
|
||||
}
|
||||
sscanf(q, "%u", &val);
|
||||
if (sscanf(q, "%u", &val) != 1)
|
||||
return 0;
|
||||
return val;
|
||||
}
|
||||
|
||||
|
@@ -515,7 +515,6 @@ ks_tuple2str(krb5_context context, int n_ks_tuple,
|
||||
{
|
||||
size_t i;
|
||||
char **ksnames;
|
||||
char *ename, *sname;
|
||||
krb5_error_code rc = KRB5_PROG_ETYPE_NOSUPP;
|
||||
|
||||
*ks_tuple_strs = NULL;
|
||||
@@ -526,11 +525,15 @@ ks_tuple2str(krb5_context context, int n_ks_tuple,
|
||||
return (errno);
|
||||
|
||||
for (i = 0; i < n_ks_tuple; i++) {
|
||||
char *ename, *sname;
|
||||
|
||||
if (krb5_enctype_to_string(context, ks_tuple[i].ks_enctype, &ename))
|
||||
goto out;
|
||||
if (krb5_salttype_to_string(context, ks_tuple[i].ks_enctype,
|
||||
ks_tuple[i].ks_salttype, &sname))
|
||||
ks_tuple[i].ks_salttype, &sname)) {
|
||||
free(ename);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (asprintf(&ksnames[i], "%s:%s", ename, sname) == -1) {
|
||||
rc = errno;
|
||||
|
Reference in New Issue
Block a user