Newer
Older
Richard Levitte
committed
ret=(ERR_STATE *)OPENSSL_malloc(sizeof(ERR_STATE));
if (ret == NULL) return(&fallback);
ret->pid=pid;
ret->top=0;
ret->bottom=0;
for (i=0; i<ERR_NUM_ERRORS; i++)
{
ret->err_data[i]=NULL;
ret->err_data_flags[i]=0;
}
tmpp = ERRFN(thread_set_item)(ret);
/* To check if insertion failed, do a get. */
if (ERRFN(thread_get_item)(ret) != ret)
{
ERR_STATE_free(ret); /* could not insert it */
return(&fallback);
}
/* If a race occured in this function and we came second, tmpp
* is the first one that we just replaced. */
ERR_STATE_free(tmpp);
err_fns_check();
return ERRFN(get_next_lib)();
void ERR_set_error_data(char *data, int flags)
{
ERR_STATE *es;
int i;
es=ERR_get_state();
i=es->top;
if (i == 0)
i=ERR_NUM_ERRORS-1;
es->err_data[i]=data;
int i,n,s;
char *str,*p,*a;
Richard Levitte
committed
str=OPENSSL_malloc(s+1);
if (str == NULL) return;
str[0]='\0';
n=0;
for (i=0; i<num; i++)
{
/* ignore NULLs, thanks to Bob Beck <beck@obtuse.com> */
if (a != NULL)
n+=strlen(a);
if (n > s)
Richard Levitte
committed
p=OPENSSL_realloc(str,s+1);
if (p == NULL)
{
Richard Levitte
committed
OPENSSL_free(str);
Richard Levitte
committed
goto err;
}
else
str=p;
}
}
ERR_set_error_data(str,ERR_TXT_MALLOCED|ERR_TXT_STRING);
Richard Levitte
committed
err:
Richard Levitte
committed
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
int ERR_set_mark(void)
{
ERR_STATE *es;
es=ERR_get_state();
if (es->bottom == es->top) return 0;
es->err_flags[es->top]|=ERR_FLAG_MARK;
return 1;
}
int ERR_pop_to_mark(void)
{
ERR_STATE *es;
es=ERR_get_state();
while(es->bottom != es->top
&& (es->err_flags[es->top] & ERR_FLAG_MARK) == 0)
{
err_clear(es,es->top);
es->top-=1;
if (es->top == -1) es->top=ERR_NUM_ERRORS-1;
Richard Levitte
committed
}
if (es->bottom == es->top) return 0;
es->err_flags[es->top]&=~ERR_FLAG_MARK;
return 1;
}