catch error from as.*printf
This commit is contained in:
@@ -1028,11 +1028,11 @@ acc_get_default_name(krb5_context context, char **str)
|
||||
return translate_cc_error(context, error);
|
||||
}
|
||||
|
||||
asprintf(str, "API:%s", name->data);
|
||||
error = asprintf(str, "API:%s", name->data);
|
||||
(*name->func->release)(name);
|
||||
(*cc->func->release)(cc);
|
||||
|
||||
if (*str == NULL) {
|
||||
if (error < 0 || *str == NULL) {
|
||||
krb5_set_error_message(context, ENOMEM, N_("malloc: out of memory", ""));
|
||||
return ENOMEM;
|
||||
}
|
||||
|
@@ -447,8 +447,9 @@ krb5_config_parse_file_multi (krb5_context context,
|
||||
fname = newfname;
|
||||
}
|
||||
#else /* KRB5_USE_PATH_TOKENS */
|
||||
asprintf(&newfname, "%%{USERCONFIG}%s", &fname[1]);
|
||||
if (newfname == NULL) {
|
||||
if (asprintf(&newfname, "%%{USERCONFIG}%s", &fname[1]) < 0 ||
|
||||
newfname == NULL)
|
||||
{
|
||||
krb5_set_error_message(context, ENOMEM,
|
||||
N_("malloc: out of memory", ""));
|
||||
return ENOMEM;
|
||||
|
@@ -96,11 +96,14 @@ krb5_vset_error_message (krb5_context context, krb5_error_code ret,
|
||||
const char *fmt, va_list args)
|
||||
__attribute__ ((format (printf, 3, 0)))
|
||||
{
|
||||
int r;
|
||||
|
||||
krb5_clear_error_message(context);
|
||||
HEIMDAL_MUTEX_lock(context->mutex);
|
||||
context->error_code = ret;
|
||||
vasprintf(&context->error_string, fmt, args);
|
||||
r = vasprintf(&context->error_string, fmt, args);
|
||||
if (r)
|
||||
context->error_string = NULL;
|
||||
HEIMDAL_MUTEX_unlock(context->mutex);
|
||||
}
|
||||
|
||||
@@ -144,19 +147,22 @@ krb5_vprepend_error_message(krb5_context context, krb5_error_code ret,
|
||||
const char *fmt, va_list args)
|
||||
__attribute__ ((format (printf, 3, 0)))
|
||||
{
|
||||
char *str, *str2;
|
||||
char *str = NULL, *str2 = NULL;
|
||||
HEIMDAL_MUTEX_lock(context->mutex);
|
||||
if (context->error_code != ret) {
|
||||
HEIMDAL_MUTEX_unlock(context->mutex);
|
||||
return;
|
||||
}
|
||||
vasprintf(&str, fmt, args);
|
||||
if (vasprintf(&str, fmt, args) < 0 || str == NULL) {
|
||||
HEIMDAL_MUTEX_unlock(context->mutex);
|
||||
return;
|
||||
}
|
||||
if (context->error_string) {
|
||||
int e;
|
||||
|
||||
e = asprintf(&str2, "%s: %s", str, context->error_string);
|
||||
free(context->error_string);
|
||||
if (e < 0)
|
||||
if (e < 0 || str2 == NULL)
|
||||
context->error_string = NULL;
|
||||
else
|
||||
context->error_string = str2;
|
||||
|
@@ -234,11 +234,12 @@ report_expiration (krb5_context context,
|
||||
const char *str,
|
||||
time_t now)
|
||||
{
|
||||
char *p;
|
||||
char *p = NULL;
|
||||
|
||||
asprintf (&p, "%s%s", str, ctime(&now));
|
||||
(*prompter) (context, data, NULL, p, 0, NULL);
|
||||
free (p);
|
||||
if (asprintf(&p, "%s%s", str, ctime(&now)) < 0 || p == NULL)
|
||||
return;
|
||||
(*prompter)(context, data, NULL, p, 0, NULL);
|
||||
free(p);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -562,10 +563,14 @@ change_password (krb5_context context,
|
||||
&result_string);
|
||||
if (ret)
|
||||
goto out;
|
||||
asprintf (&p, "%s: %.*s\n",
|
||||
result_code ? "Error" : "Success",
|
||||
(int)result_string.length,
|
||||
result_string.length > 0 ? (char*)result_string.data : "");
|
||||
if (asprintf(&p, "%s: %.*s\n",
|
||||
result_code ? "Error" : "Success",
|
||||
(int)result_string.length,
|
||||
result_string.length > 0 ? (char*)result_string.data : "") < 0)
|
||||
{
|
||||
ret = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* return the result */
|
||||
(*prompter) (context, data, NULL, p, 0, NULL);
|
||||
|
@@ -448,7 +448,7 @@ static krb5_error_code
|
||||
fallback_get_hosts(krb5_context context, struct krb5_krbhst_data *kd,
|
||||
const char *serv_string, int port, int proto)
|
||||
{
|
||||
char *host;
|
||||
char *host = NULL;
|
||||
int ret;
|
||||
struct addrinfo *ai;
|
||||
struct addrinfo hints;
|
||||
@@ -467,12 +467,12 @@ fallback_get_hosts(krb5_context context, struct krb5_krbhst_data *kd,
|
||||
}
|
||||
|
||||
if(kd->fallback_count == 0)
|
||||
asprintf(&host, "%s.%s.", serv_string, kd->realm);
|
||||
ret = asprintf(&host, "%s.%s.", serv_string, kd->realm);
|
||||
else
|
||||
asprintf(&host, "%s-%d.%s.",
|
||||
serv_string, kd->fallback_count, kd->realm);
|
||||
ret = asprintf(&host, "%s-%d.%s.",
|
||||
serv_string, kd->fallback_count, kd->realm);
|
||||
|
||||
if (host == NULL)
|
||||
if (ret < 0 || host == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
make_hints(&hints, proto);
|
||||
|
@@ -67,15 +67,16 @@ static krb5_mcache *
|
||||
mcc_alloc(const char *name)
|
||||
{
|
||||
krb5_mcache *m, *m_c;
|
||||
int ret = 0;
|
||||
|
||||
ALLOC(m, 1);
|
||||
if(m == NULL)
|
||||
return NULL;
|
||||
if(name == NULL)
|
||||
asprintf(&m->name, "%p", m);
|
||||
ret = asprintf(&m->name, "%p", m);
|
||||
else
|
||||
m->name = strdup(name);
|
||||
if(m->name == NULL) {
|
||||
if(ret < 0 || m->name == NULL) {
|
||||
free(m);
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -226,17 +226,18 @@ load_plugins(krb5_context context)
|
||||
continue;
|
||||
|
||||
path = NULL;
|
||||
ret = 0;
|
||||
#ifdef __APPLE__
|
||||
{ /* support loading bundles on MacOS */
|
||||
size_t len = strlen(n);
|
||||
if (len > 7 && strcmp(&n[len - 7], ".bundle") == 0)
|
||||
asprintf(&path, "%s/%s/Contents/MacOS/%.*s", *di, n, (int)(len - 7), n);
|
||||
ret = asprintf(&path, "%s/%s/Contents/MacOS/%.*s", *di, n, (int)(len - 7), n);
|
||||
}
|
||||
#endif
|
||||
if (path == NULL)
|
||||
asprintf(&path, "%s/%s", *di, n);
|
||||
if (ret < 0 || path == NULL)
|
||||
ret = asprintf(&path, "%s/%s", *di, n);
|
||||
|
||||
if (path == NULL) {
|
||||
if (ret < 0 || path == NULL) {
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
return ret;
|
||||
|
@@ -308,12 +308,12 @@ krb5_get_server_rcache(krb5_context context,
|
||||
}
|
||||
strvisx(tmp, piece->data, piece->length, VIS_WHITE | VIS_OCTAL);
|
||||
#ifdef HAVE_GETEUID
|
||||
asprintf(&name, "FILE:rc_%s_%u", tmp, (unsigned)geteuid());
|
||||
ret = asprintf(&name, "FILE:rc_%s_%u", tmp, (unsigned)geteuid());
|
||||
#else
|
||||
asprintf(&name, "FILE:rc_%s", tmp);
|
||||
ret = asprintf(&name, "FILE:rc_%s", tmp);
|
||||
#endif
|
||||
free(tmp);
|
||||
if(name == NULL) {
|
||||
if(ret < 0 || name == NULL) {
|
||||
krb5_set_error_message(context, ENOMEM,
|
||||
N_("malloc: out of memory", ""));
|
||||
return ENOMEM;
|
||||
|
@@ -296,6 +296,7 @@ out:
|
||||
static krb5_scache *
|
||||
scc_alloc(krb5_context context, const char *name)
|
||||
{
|
||||
krb5_error_code ret;
|
||||
krb5_scache *s;
|
||||
|
||||
ALLOC(s, 1);
|
||||
@@ -319,14 +320,15 @@ scc_alloc(krb5_context context, const char *name)
|
||||
if (file) {
|
||||
*file++ = '\0';
|
||||
s->file = strdup(file);
|
||||
ret = 0;
|
||||
} else {
|
||||
_krb5_expand_default_cc_name(context, KRB5_SCACHE_DB, &s->file);
|
||||
ret = _krb5_expand_default_cc_name(context, KRB5_SCACHE_DB, &s->file);
|
||||
}
|
||||
} else {
|
||||
_krb5_expand_default_cc_name(context, KRB5_SCACHE_DB, &s->file);
|
||||
asprintf(&s->name, "unique-%p", s);
|
||||
ret = asprintf(&s->name, "unique-%p", s);
|
||||
}
|
||||
if (s->file == NULL || s->name == NULL) {
|
||||
if (ret < 0 || s->file == NULL || s->name == NULL) {
|
||||
scc_free(s);
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user