Dear List,
 Test Program:

#include <openssl/err.h>
#include <openssl/bio.h>
#include <openssl/dso.h>
#include <string.h>

int main()
{
        BIO *bio_err=NULL;
        int i;
        long f=DSO_F_DLFCN_BIND_FUNC;
        char buf[10];

        bio_err=BIO_new(BIO_s_file());
        BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);

        for(i=0;i<ERR_NUM_ERRORS-1;i++,f++) /* line 17 */
        {
       DSOerr(f,DSO_R_SYM_FAILURE);
                sprintf(buf,"%d",i);
                ERR_add_error_data(1,buf);
        }

        ERR_print_errors(bio_err);
        return 0;
}

The Output:
2172:error:2506406A:lib(37):func(100):reason(106):c:\temp\errtest\main.c:19:0

2172:error:2506506A:lib(37):func(101):reason(106):c:\temp\errtest\main.c:19:1

2172:error:2506606A:lib(37):func(102):reason(106):c:\temp\errtest\main.c:19:2

2172:error:2506706A:lib(37):func(103):reason(106):c:\temp\errtest\main.c:19:3

2172:error:2506806A:lib(37):func(104):reason(106):c:\temp\errtest\main.c:19:4

2172:error:2506906A:lib(37):func(105):reason(106):c:\temp\errtest\main.c:19:5

2172:error:2506A06A:lib(37):func(106):reason(106):c:\temp\errtest\main.c:19:6

2172:error:2506B06A:lib(37):func(107):reason(106):c:\temp\errtest\main.c:19:7

2172:error:2506C06A:lib(37):func(108):reason(106):c:\temp\errtest\main.c:19:8

2172:error:2506D06A:lib(37):func(109):reason(106):c:\temp\errtest\main.c:19:9

2172:error:2506E06A:lib(37):func(110):reason(106):c:\temp\errtest\main.c:19:10

2172:error:2506F06A:lib(37):func(111):reason(106):c:\temp\errtest\main.c:19:11

2172:error:2507006A:lib(37):func(112):reason(106):c:\temp\errtest\main.c:19:12

2172:error:2507106A:lib(37):func(113):reason(106):c:\temp\errtest\main.c:19:13

2172:error:2507206A:lib(37):func(114):reason(106):c:\temp\errtest\main.c:19:14


That is OK. When I change the line 17 to for(i=0;i<ERR_NUM_ERRORS;i++,f++)

The Ouput:
2172:error:2506506A:lib(37):func(101):reason(106):c:\temp\errtest\main.c:19:1

2172:error:2506606A:lib(37):func(102):reason(106):c:\temp\errtest\main.c:19:2

2172:error:2506706A:lib(37):func(103):reason(106):c:\temp\errtest\main.c:19:3

2172:error:2506806A:lib(37):func(104):reason(106):c:\temp\errtest\main.c:19:4

2172:error:2506906A:lib(37):func(105):reason(106):c:\temp\errtest\main.c:19:5

2172:error:2506A06A:lib(37):func(106):reason(106):c:\temp\errtest\main.c:19:6

2172:error:2506B06A:lib(37):func(107):reason(106):c:\temp\errtest\main.c:19:7

2172:error:2506C06A:lib(37):func(108):reason(106):c:\temp\errtest\main.c:19:8

2172:error:2506D06A:lib(37):func(109):reason(106):c:\temp\errtest\main.c:19:9

2172:error:2506E06A:lib(37):func(110):reason(106):c:\temp\errtest\main.c:19:10

2172:error:2506F06A:lib(37):func(111):reason(106):c:\temp\errtest\main.c:19:11

2172:error:2507006A:lib(37):func(112):reason(106):c:\temp\errtest\main.c:19:12

2172:error:2507106A:lib(37):func(113):reason(106):c:\temp\errtest\main.c:19:13

2172:error:2507206A:lib(37):func(114):reason(106):c:\temp\errtest\main.c:19:15

2172:error:2507306A:lib(37):func(115):reason(106):c:\temp\errtest\main.c:19:


That is wrong.func(114)'s err_data should is 14 ,not 15.And func(115)'s err_data should is 15.


When I look into openssl's source,I find the ERR_set_error_data function is as follows:
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;

err_clear_data(es,i);
es->err_data[i]=data;
es->err_data_flags[i]=flags;
}
if (i == 0)
i=ERR_NUM_ERRORS-1;
Why?
I think this statement should be deleted.I delelted it ,and recompile openssl,link the test program.
The Output is:
1992:error:2506506A:lib(37):func(101):reason(106):c:\temp\errtest\main.c:19:1


1992:error:2506606A:lib(37):func(102):reason(106):c:\temp\errtest\main.c:19:2

1992:error:2506706A:lib(37):func(103):reason(106):c:\temp\errtest\main.c:19:3

1992:error:2506806A:lib(37):func(104):reason(106):c:\temp\errtest\main.c:19:4

1992:error:2506906A:lib(37):func(105):reason(106):c:\temp\errtest\main.c:19:5

1992:error:2506A06A:lib(37):func(106):reason(106):c:\temp\errtest\main.c:19:6

1992:error:2506B06A:lib(37):func(107):reason(106):c:\temp\errtest\main.c:19:7

1992:error:2506C06A:lib(37):func(108):reason(106):c:\temp\errtest\main.c:19:8

1992:error:2506D06A:lib(37):func(109):reason(106):c:\temp\errtest\main.c:19:9

1992:error:2506E06A:lib(37):func(110):reason(106):c:\temp\errtest\main.c:19:10

1992:error:2506F06A:lib(37):func(111):reason(106):c:\temp\errtest\main.c:19:11

1992:error:2507006A:lib(37):func(112):reason(106):c:\temp\errtest\main.c:19:12

1992:error:2507106A:lib(37):func(113):reason(106):c:\temp\errtest\main.c:19:13

1992:error:2507206A:lib(37):func(114):reason(106):c:\temp\errtest\main.c:19:14

1992:error:2507306A:lib(37):func(115):reason(106):c:\temp\errtest\main.c:19:15


That's OK.

                                                              zhao min
                                                              2005.1.31

_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [email protected]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to