apps/s_server.c:3035: error: BUFFER_OVERRUN_L3
  Offset: [-529, +oo] Size: 12 by call to `X509_print`.
Showing all 18 steps of the trace


apps/s_server.c:3019:4: Call
3017.   				}
3018.   			ssl_print_sigalgs(io, con);
3019.   			ssl_print_curves(io, con, 0);
           ^
3020.   			BIO_printf(io,(SSL_cache_hit(con)
3021.   				?"---\nReused, "

apps/s_cb.c:431:12: Call
  429.   	int i, ncurves, *curves, nid;
  430.   	const char *cname;
  431.   	ncurves = SSL_get1_curves(s, NULL);
                    ^
  432.   	if (ncurves <= 0)
  433.   		return 1;

ssl/ssl_lib.c:1078:1: Parameter `*parg`
    1076.   	}
    1077.   
    1078. > long SSL_ctrl(SSL *s,int cmd,long larg,void *parg)
    1079.   	{
    1080.   	long l;

apps/s_server.c:3027:4: Call
3025.   				SSL_CIPHER_get_version(c),
3026.   				SSL_CIPHER_get_name(c));
3027.   			SSL_SESSION_print(io,SSL_get_session(con));
           ^
3028.   			BIO_printf(io,"---\n");
3029.   			print_stats(io,SSL_get_SSL_CTX(con));

ssl/ssl_txt.c:107:1: Parameter `*x->tlsext_tick`
  105.   #endif
  106.   
  107. > int SSL_SESSION_print(BIO *bp, const SSL_SESSION *x)
  108.   	{
  109.   	unsigned int i;

apps/s_server.c:3035:5: Call
3033.   				{
3034.   				BIO_printf(io,"Client certificate\n");
3035.   				X509_print(io,peer);
            ^
3036.   				PEM_write_bio_X509(io,peer);
3037.   				}

crypto/asn1/t_x509.c:100:1: Parameter `*x->cert_info->validity->notAfter->data`
  98.   #endif
  99.   
  100. > int X509_print(BIO *bp, X509 *x)
  101.   {
  102.   	return X509_print_ex(bp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT);

crypto/asn1/t_x509.c:102:9: Call
  100.   int X509_print(BIO *bp, X509 *x)
  101.   {
  102.   	return X509_print_ex(bp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT);
                 ^
  103.   }
  104.   

crypto/asn1/t_x509.c:105:1: Parameter `*x->cert_info->validity->notAfter->data`
    103.   }
    104.   
    105. > int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
    106.   	{
    107.   	long l;

crypto/asn1/t_x509.c:195:8: Call
    193.   		if (!ASN1_TIME_print(bp,X509_get_notBefore(x))) goto err;
    194.   		if (BIO_write(bp,"\n            Not After : ",25) <= 0) goto err;
    195.   		if (!ASN1_TIME_print(bp,X509_get_notAfter(x))) goto err;
                  ^
    196.   		if (BIO_write(bp,"\n",1) <= 0) goto err;
    197.   		}

crypto/asn1/t_x509.c:389:1: Parameter `*tm->data`
      387.   	}
      388.   
      389. > int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)
      390.   {
      391.   	if(tm->type == V_ASN1_UTCTIME) return ASN1_UTCTIME_print(bp, tm);

crypto/asn1/t_x509.c:393:12: Call
      391.   	if(tm->type == V_ASN1_UTCTIME) return ASN1_UTCTIME_print(bp, tm);
      392.   	if(tm->type == V_ASN1_GENERALIZEDTIME)
      393.   				return ASN1_GENERALIZEDTIME_print(bp, tm);
                        ^
      394.   	BIO_write(bp,"Bad time value",14);
      395.   	return(0);

crypto/asn1/t_x509.c:404:1: <Offset trace>
402.       };
403.   
404. > int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)
405.   	{
406.   	char *v;

crypto/asn1/t_x509.c:404:1: Parameter `*tm->data`
        402.       };
        403.   
        404. > int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)
        405.   	{
        406.   	char *v;

crypto/asn1/t_x509.c:421:2: Assignment
        419.   		if ((v[i] > '9') || (v[i] < '0')) goto err;
        420.   	y= (v[0]-'0')*1000+(v[1]-'0')*100 + (v[2]-'0')*10+(v[3]-'0');
        421.   	M= (v[4]-'0')*10+(v[5]-'0');
                ^
        422.   	if ((M > 12) || (M < 1)) goto err;
        423.   	d= (v[6]-'0')*10+(v[7]-'0');

crypto/asn1/t_x509.c:398:1: <Length trace>
396.   }
397.   
398. > static const char *mon[12]=
399.       {
400.       "Jan","Feb","Mar","Apr","May","Jun",

crypto/asn1/t_x509.c:398:1: Array declaration
        396.   }
        397.   
        398. > static const char *mon[12]=
        399.       {
        400.       "Jan","Feb","Mar","Apr","May","Jun",

crypto/asn1/t_x509.c:443:3: Array access: Offset: [-529, +oo] Size: 12 by call to `X509_print` 
        441.   
        442.   	if (BIO_printf(bp,"%s %2d %02d:%02d:%02d%.*s %d%s",
        443.   		mon[M-1],d,h,m,s,f_len,f,y,(gmt)?" GMT":"") <= 0)
                 ^
        444.   		return(0);
        445.   	else

int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)
	{
	char *v;
	int gmt=0;
	int i;
	int y=0,M=0,d=0,h=0,m=0,s=0;
	char *f = NULL;
	int f_len = 0;
	i=tm->length;
	v=(char *)tm->data;
	if (i < 12) goto err;
	if (v[i-1] == 'Z') gmt=1;
	for (i=0; i<12; i++)
		if ((v[i] > '9') || (v[i] < '0')) goto err;
	y= (v[0]-'0')*1000+(v[1]-'0')*100 + (v[2]-'0')*10+(v[3]-'0');
	M= (v[4]-'0')*10+(v[5]-'0');
	if ((M > 12) || (M < 1)) goto err;
	d= (v[6]-'0')*10+(v[7]-'0');
	h= (v[8]-'0')*10+(v[9]-'0');
	m=  (v[10]-'0')*10+(v[11]-'0');
	if (tm->length >= 14 &&
	    (v[12] >= '0') && (v[12] <= '9') &&
	    (v[13] >= '0') && (v[13] <= '9'))
		{
		s=  (v[12]-'0')*10+(v[13]-'0');
		if (tm->length >= 15 && v[14] == '.')
			{
			int l = tm->length;
			f = &v[14];
			f_len = 1;
			while (14 + f_len < l && f[f_len] >= '0' && f[f_len] <= '9')
				++f_len;
			}
		}
	if (BIO_printf(bp,"%s %2d %02d:%02d:%02d%.*s %d%s",
		mon[M-1],d,h,m,s,f_len,f,y,(gmt)?" GMT":"") <= 0)
		return(0);
	else
		return(1);
err:
	BIO_write(bp,"Bad time value",14);
	return(0);
	}
['static int www_body(char *hostname, int s, unsigned char *context)\n\t{\n\tchar *buf=NULL;\n\tint ret=1;\n\tint i,j,k,dot;\n\tSSL *con;\n\tconst SSL_CIPHER *c;\n\tBIO *io,*ssl_bio,*sbio;\n#ifndef OPENSSL_NO_KRB5\n\tKSSL_CTX *kctx;\n#endif\n\tbuf=OPENSSL_malloc(bufsize);\n\tif (buf == NULL) return(0);\n\tio=BIO_new(BIO_f_buffer());\n\tssl_bio=BIO_new(BIO_f_ssl());\n\tif ((io == NULL) || (ssl_bio == NULL)) goto err;\n#ifdef FIONBIO\n\tif (s_nbio)\n\t\t{\n\t\tunsigned long sl=1;\n\t\tif (!s_quiet)\n\t\t\tBIO_printf(bio_err,"turning on non blocking io\\n");\n\t\tif (BIO_socket_ioctl(s,FIONBIO,&sl) < 0)\n\t\t\tERR_print_errors(bio_err);\n\t\t}\n#endif\n\tif (!BIO_set_write_buffer_size(io,bufsize)) goto err;\n\tif ((con=SSL_new(ctx)) == NULL) goto err;\n#ifndef OPENSSL_NO_TLSEXT\n\t\tif (s_tlsextdebug)\n\t\t\t{\n\t\t\tSSL_set_tlsext_debug_callback(con, tlsext_cb);\n\t\t\tSSL_set_tlsext_debug_arg(con, bio_s_out);\n\t\t\t}\n#endif\n#ifndef OPENSSL_NO_KRB5\n\tif ((kctx = kssl_ctx_new()) != NULL)\n\t\t{\n\t\tkssl_ctx_setstring(kctx, KSSL_SERVICE, KRB5SVC);\n\t\tkssl_ctx_setstring(kctx, KSSL_KEYTAB, KRB5KEYTAB);\n\t\t}\n#endif\n\tif(context) SSL_set_session_id_context(con, context,\n\t\t\t\t\t       strlen((char *)context));\n\tsbio=BIO_new_socket(s,BIO_NOCLOSE);\n\tif (s_nbio_test)\n\t\t{\n\t\tBIO *test;\n\t\ttest=BIO_new(BIO_f_nbio_test());\n\t\tsbio=BIO_push(test,sbio);\n\t\t}\n\tSSL_set_bio(con,sbio,sbio);\n\tSSL_set_accept_state(con);\n\tBIO_set_ssl(ssl_bio,con,BIO_CLOSE);\n\tBIO_push(io,ssl_bio);\n#ifdef CHARSET_EBCDIC\n\tio = BIO_push(BIO_new(BIO_f_ebcdic_filter()),io);\n#endif\n\tif (s_debug)\n\t\t{\n\t\tSSL_set_debug(con, 1);\n\t\tBIO_set_callback(SSL_get_rbio(con),bio_dump_callback);\n\t\tBIO_set_callback_arg(SSL_get_rbio(con),(char *)bio_s_out);\n\t\t}\n\tif (s_msg)\n\t\t{\n#ifndef OPENSSL_NO_SSL_TRACE\n\t\tif (s_msg == 2)\n\t\t\tSSL_set_msg_callback(con, SSL_trace);\n\t\telse\n#endif\n\t\t\tSSL_set_msg_callback(con, msg_cb);\n\t\tSSL_set_msg_callback_arg(con, bio_s_msg ? bio_s_msg : bio_s_out);\n\t\t}\n\tfor (;;)\n\t\t{\n\t\tif (hack)\n\t\t\t{\n\t\t\ti=SSL_accept(con);\n#ifndef OPENSSL_NO_SRP\n\t\t\twhile (i <= 0 &&  SSL_get_error(con,i) == SSL_ERROR_WANT_X509_LOOKUP)\n\t\t{\n\t\t\tBIO_printf(bio_s_out,"LOOKUP during accept %s\\n",srp_callback_parm.login);\n\t\t\tsrp_callback_parm.user = SRP_VBASE_get_by_user(srp_callback_parm.vb, srp_callback_parm.login);\n\t\t\tif (srp_callback_parm.user)\n\t\t\t\tBIO_printf(bio_s_out,"LOOKUP done %s\\n",srp_callback_parm.user->info);\n\t\t\telse\n\t\t\t\tBIO_printf(bio_s_out,"LOOKUP not successful\\n");\n\t\t\ti=SSL_accept(con);\n\t\t}\n#endif\n\t\t\tswitch (SSL_get_error(con,i))\n\t\t\t\t{\n\t\t\tcase SSL_ERROR_NONE:\n\t\t\t\tbreak;\n\t\t\tcase SSL_ERROR_WANT_WRITE:\n\t\t\tcase SSL_ERROR_WANT_READ:\n\t\t\tcase SSL_ERROR_WANT_X509_LOOKUP:\n\t\t\t\tcontinue;\n\t\t\tcase SSL_ERROR_SYSCALL:\n\t\t\tcase SSL_ERROR_SSL:\n\t\t\tcase SSL_ERROR_ZERO_RETURN:\n\t\t\t\tret=1;\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tSSL_renegotiate(con);\n\t\t\tSSL_write(con,NULL,0);\n\t\t\t}\n\t\ti=BIO_gets(io,buf,bufsize-1);\n\t\tif (i < 0)\n\t\t\t{\n\t\t\tif (!BIO_should_retry(io))\n\t\t\t\t{\n\t\t\t\tif (!s_quiet)\n\t\t\t\t\tERR_print_errors(bio_err);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tBIO_printf(bio_s_out,"read R BLOCK\\n");\n#if defined(OPENSSL_SYS_NETWARE)\n            delay(1000);\n#elif !defined(OPENSSL_SYS_MSDOS) && !defined(__DJGPP__)\n\t\t\t\tsleep(1);\n#endif\n\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\telse if (i == 0)\n\t\t\t{\n\t\t\tret=1;\n\t\t\tgoto end;\n\t\t\t}\n\t\tif (\t((www == 1) && (strncmp("GET ",buf,4) == 0)) ||\n\t\t\t((www == 2) && (strncmp("GET /stats ",buf,10) == 0)))\n\t\t\t{\n\t\t\tchar *p;\n\t\t\tX509 *peer;\n\t\t\tSTACK_OF(SSL_CIPHER) *sk;\n\t\t\tstatic const char *space="                          ";\n\t\tif (www == 1 && strncmp("GET /reneg", buf, 10) == 0)\n\t\t\t{\n\t\t\tif (strncmp("GET /renegcert", buf, 14) == 0)\n\t\t\t\tSSL_set_verify(con,\n\t\t\t\tSSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,NULL);\n\t\t\ti=SSL_renegotiate(con);\n\t\t\tBIO_printf(bio_s_out, "SSL_renegotiate -> %d\\n",i);\n\t\t\ti=SSL_do_handshake(con);\n\t\t\tif (i <= 0)\n\t\t\t\t{\n\t\t\t\tBIO_printf(bio_s_out, "SSL_do_handshake() Retval %d\\n", SSL_get_error(con, i));\n\t\t\t\tERR_print_errors(bio_err);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tSSL_set_state(con, SSL_ST_ACCEPT);\n\t\t\ti=SSL_do_handshake(con);\n\t\t\tBIO_printf(bio_s_out, "SSL_do_handshake -> %d\\n",i);\n\t\t\tif (i <= 0)\n\t\t\t\t{\n\t\t\t\tBIO_printf(bio_s_out, "SSL_do_handshake() Retval %d\\n", SSL_get_error(con, i));\n\t\t\t\tERR_print_errors(bio_err);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t}\n\t\t\tBIO_puts(io,"HTTP/1.0 200 ok\\r\\nContent-type: text/html\\r\\n\\r\\n");\n\t\t\tBIO_puts(io,"<HTML><BODY BGCOLOR=\\"#ffffff\\">\\n");\n\t\t\tBIO_puts(io,"<pre>\\n");\n\t\t\tBIO_puts(io,"\\n");\n\t\t\tfor (i=0; i<local_argc; i++)\n\t\t\t\t{\n\t\t\t\tBIO_puts(io,local_argv[i]);\n\t\t\t\tBIO_write(io," ",1);\n\t\t\t\t}\n\t\t\tBIO_puts(io,"\\n");\n\t\t\tBIO_printf(io,\n\t\t\t\t"Secure Renegotiation IS%s supported\\n",\n\t\t      \t\tSSL_get_secure_renegotiation_support(con) ?\n\t\t\t\t\t\t\t"" : " NOT");\n\t\t\tBIO_printf(io,"Ciphers supported in s_server binary\\n");\n\t\t\tsk=SSL_get_ciphers(con);\n\t\t\tj=sk_SSL_CIPHER_num(sk);\n\t\t\tfor (i=0; i<j; i++)\n\t\t\t\t{\n\t\t\t\tc=sk_SSL_CIPHER_value(sk,i);\n\t\t\t\tBIO_printf(io,"%-11s:%-25s",\n\t\t\t\t\tSSL_CIPHER_get_version(c),\n\t\t\t\t\tSSL_CIPHER_get_name(c));\n\t\t\t\tif ((((i+1)%2) == 0) && (i+1 != j))\n\t\t\t\t\tBIO_puts(io,"\\n");\n\t\t\t\t}\n\t\t\tBIO_puts(io,"\\n");\n\t\t\tp=SSL_get_shared_ciphers(con,buf,bufsize);\n\t\t\tif (p != NULL)\n\t\t\t\t{\n\t\t\t\tBIO_printf(io,"---\\nCiphers common between both SSL end points:\\n");\n\t\t\t\tj=i=0;\n\t\t\t\twhile (*p)\n\t\t\t\t\t{\n\t\t\t\t\tif (*p == \':\')\n\t\t\t\t\t\t{\n\t\t\t\t\t\tBIO_write(io,space,26-j);\n\t\t\t\t\t\ti++;\n\t\t\t\t\t\tj=0;\n\t\t\t\t\t\tBIO_write(io,((i%3)?" ":"\\n"),1);\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\tBIO_write(io,p,1);\n\t\t\t\t\t\tj++;\n\t\t\t\t\t\t}\n\t\t\t\t\tp++;\n\t\t\t\t\t}\n\t\t\t\tBIO_puts(io,"\\n");\n\t\t\t\t}\n\t\t\tssl_print_sigalgs(io, con);\n\t\t\tssl_print_curves(io, con, 0);\n\t\t\tBIO_printf(io,(SSL_cache_hit(con)\n\t\t\t\t?"---\\nReused, "\n\t\t\t\t:"---\\nNew, "));\n\t\t\tc=SSL_get_current_cipher(con);\n\t\t\tBIO_printf(io,"%s, Cipher is %s\\n",\n\t\t\t\tSSL_CIPHER_get_version(c),\n\t\t\t\tSSL_CIPHER_get_name(c));\n\t\t\tSSL_SESSION_print(io,SSL_get_session(con));\n\t\t\tBIO_printf(io,"---\\n");\n\t\t\tprint_stats(io,SSL_get_SSL_CTX(con));\n\t\t\tBIO_printf(io,"---\\n");\n\t\t\tpeer=SSL_get_peer_certificate(con);\n\t\t\tif (peer != NULL)\n\t\t\t\t{\n\t\t\t\tBIO_printf(io,"Client certificate\\n");\n\t\t\t\tX509_print(io,peer);\n\t\t\t\tPEM_write_bio_X509(io,peer);\n\t\t\t\t}\n\t\t\telse\n\t\t\t\tBIO_puts(io,"no client certificate available\\n");\n\t\t\tBIO_puts(io,"</BODY></HTML>\\r\\n\\r\\n");\n\t\t\tbreak;\n\t\t\t}\n\t\telse if ((www == 2 || www == 3)\n                         && (strncmp("GET /",buf,5) == 0))\n\t\t\t{\n\t\t\tBIO *file;\n\t\t\tchar *p,*e;\n\t\t\tstatic const char *text="HTTP/1.0 200 ok\\r\\nContent-type: text/plain\\r\\n\\r\\n";\n\t\t\tp= &(buf[5]);\n\t\t\tdot = 1;\n\t\t\tfor (e=p; *e != \'\\0\'; e++)\n\t\t\t\t{\n\t\t\t\tif (e[0] == \' \')\n\t\t\t\t\tbreak;\n\t\t\t\tswitch (dot)\n\t\t\t\t\t{\n\t\t\t\tcase 1:\n\t\t\t\t\tdot = (e[0] == \'.\') ? 2 : 0;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\tdot = (e[0] == \'.\') ? 3 : 0;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3:\n\t\t\t\t\tdot = (e[0] == \'/\') ? -1 : 0;\n\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\tif (dot == 0)\n\t\t\t\t\tdot = (e[0] == \'/\') ? 1 : 0;\n\t\t\t\t}\n\t\t\tdot = (dot == 3) || (dot == -1);\n\t\t\tif (*e == \'\\0\')\n\t\t\t\t{\n\t\t\t\tBIO_puts(io,text);\n\t\t\t\tBIO_printf(io,"\'%s\' is an invalid file name\\r\\n",p);\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t*e=\'\\0\';\n\t\t\tif (dot)\n\t\t\t\t{\n\t\t\t\tBIO_puts(io,text);\n\t\t\t\tBIO_printf(io,"\'%s\' contains \'..\' reference\\r\\n",p);\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tif (*p == \'/\')\n\t\t\t\t{\n\t\t\t\tBIO_puts(io,text);\n\t\t\t\tBIO_printf(io,"\'%s\' is an invalid path\\r\\n",p);\n\t\t\t\tbreak;\n\t\t\t\t}\n#if 0\n\t\t\tif (e[-1] == \'/\')\n\t\t\t\tstrcat(p,"index.html");\n#endif\n\t\t\tif (app_isdir(p)>0)\n\t\t\t\t{\n#if 0\n\t\t\t\tstrcat(p,"/index.html");\n#else\n\t\t\t\tBIO_puts(io,text);\n\t\t\t\tBIO_printf(io,"\'%s\' is a directory\\r\\n",p);\n\t\t\t\tbreak;\n#endif\n\t\t\t\t}\n\t\t\tif ((file=BIO_new_file(p,"r")) == NULL)\n\t\t\t\t{\n\t\t\t\tBIO_puts(io,text);\n\t\t\t\tBIO_printf(io,"Error opening \'%s\'\\r\\n",p);\n\t\t\t\tERR_print_errors(io);\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tif (!s_quiet)\n\t\t\t\tBIO_printf(bio_err,"FILE:%s\\n",p);\n                        if (www == 2)\n                                {\n                                i=strlen(p);\n                                if (\t((i > 5) && (strcmp(&(p[i-5]),".html") == 0)) ||\n                                        ((i > 4) && (strcmp(&(p[i-4]),".php") == 0)) ||\n                                        ((i > 4) && (strcmp(&(p[i-4]),".htm") == 0)))\n                                        BIO_puts(io,"HTTP/1.0 200 ok\\r\\nContent-type: text/html\\r\\n\\r\\n");\n                                else\n                                        BIO_puts(io,"HTTP/1.0 200 ok\\r\\nContent-type: text/plain\\r\\n\\r\\n");\n                                }\n\t\t\tfor (;;)\n\t\t\t\t{\n\t\t\t\ti=BIO_read(file,buf,bufsize);\n\t\t\t\tif (i <= 0) break;\n#ifdef RENEG\n\t\t\t\ttotal_bytes+=i;\n\t\t\t\tfprintf(stderr,"%d\\n",i);\n\t\t\t\tif (total_bytes > 3*1024)\n\t\t\t\t\t{\n\t\t\t\t\ttotal_bytes=0;\n\t\t\t\t\tfprintf(stderr,"RENEGOTIATE\\n");\n\t\t\t\t\tSSL_renegotiate(con);\n\t\t\t\t\t}\n#endif\n\t\t\t\tfor (j=0; j<i; )\n\t\t\t\t\t{\n#ifdef RENEG\n{ static count=0; if (++count == 13) { SSL_renegotiate(con); } }\n#endif\n\t\t\t\t\tk=BIO_write(io,&(buf[j]),i-j);\n\t\t\t\t\tif (k <= 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tif (!BIO_should_retry(io))\n\t\t\t\t\t\t\tgoto write_error;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\tBIO_printf(bio_s_out,"rwrite W BLOCK\\n");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\tj+=k;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\nwrite_error:\n\t\t\tBIO_free(file);\n\t\t\tbreak;\n\t\t\t}\n\t\t}\n\tfor (;;)\n\t\t{\n\t\ti=(int)BIO_flush(io);\n\t\tif (i <= 0)\n\t\t\t{\n\t\t\tif (!BIO_should_retry(io))\n\t\t\t\tbreak;\n\t\t\t}\n\t\telse\n\t\t\tbreak;\n\t\t}\nend:\n#if 1\n\tSSL_set_shutdown(con,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);\n#else\n#endif\nerr:\n\tif (ret >= 0)\n\t\tBIO_printf(bio_s_out,"ACCEPT\\n");\n\tif (buf != NULL) OPENSSL_free(buf);\n\tif (io != NULL) BIO_free_all(io);\n\treturn(ret);\n\t}', 'int ssl_print_curves(BIO *out, SSL *s, int noshared)\n\t{\n\tint i, ncurves, *curves, nid;\n\tconst char *cname;\n\tncurves = SSL_get1_curves(s, NULL);\n\tif (ncurves <= 0)\n\t\treturn 1;\n\tcurves = OPENSSL_malloc(ncurves * sizeof(int));\n\tSSL_get1_curves(s, curves);\n\tBIO_puts(out, "Supported Elliptic Curves: ");\n\tfor (i = 0; i < ncurves; i++)\n\t\t{\n\t\tif (i)\n\t\t\tBIO_puts(out, ":");\n\t\tnid = curves[i];\n\t\tif (nid & TLSEXT_nid_unknown)\n\t\t\tBIO_printf(out, "0x%04X", nid & 0xFFFF);\n\t\telse\n\t\t\t{\n\t\t\tcname = EC_curve_nid2nist(nid);\n\t\t\tif (!cname)\n\t\t\t\tcname = OBJ_nid2sn(nid);\n\t\t\tBIO_printf(out, "%s", cname);\n\t\t\t}\n\t\t}\n\tif (ncurves == 0)\n\t\tBIO_puts(out, "NONE");\n\tif (noshared)\n\t\t{\n\t\tBIO_puts(out, "\\n");\n\t\treturn 1;\n\t\t}\n\tBIO_puts(out, "\\nShared Elliptic curves: ");\n\tOPENSSL_free(curves);\n\tncurves = SSL_get_shared_curve(s, -1);\n\tfor (i = 0; i < ncurves; i++)\n\t\t{\n\t\tif (i)\n\t\t\tBIO_puts(out, ":");\n\t\tnid = SSL_get_shared_curve(s, i);\n\t\tcname = EC_curve_nid2nist(nid);\n\t\tif (!cname)\n\t\t\tcname = OBJ_nid2sn(nid);\n\t\tBIO_printf(out, "%s", cname);\n\t\t}\n\tif (ncurves == 0)\n\t\tBIO_puts(out, "NONE");\n\tBIO_puts(out, "\\n");\n\treturn 1;\n\t}', 'long SSL_ctrl(SSL *s,int cmd,long larg,void *parg)\n\t{\n\tlong l;\n\tswitch (cmd)\n\t\t{\n\tcase SSL_CTRL_GET_READ_AHEAD:\n\t\treturn(s->read_ahead);\n\tcase SSL_CTRL_SET_READ_AHEAD:\n\t\tl=s->read_ahead;\n\t\ts->read_ahead=larg;\n\t\treturn(l);\n\tcase SSL_CTRL_SET_MSG_CALLBACK_ARG:\n\t\ts->msg_callback_arg = parg;\n\t\treturn 1;\n\tcase SSL_CTRL_OPTIONS:\n\t\treturn(s->options|=larg);\n\tcase SSL_CTRL_CLEAR_OPTIONS:\n\t\treturn(s->options&=~larg);\n\tcase SSL_CTRL_MODE:\n\t\treturn(s->mode|=larg);\n\tcase SSL_CTRL_CLEAR_MODE:\n\t\treturn(s->mode &=~larg);\n\tcase SSL_CTRL_GET_MAX_CERT_LIST:\n\t\treturn(s->max_cert_list);\n\tcase SSL_CTRL_SET_MAX_CERT_LIST:\n\t\tl=s->max_cert_list;\n\t\ts->max_cert_list=larg;\n\t\treturn(l);\n\tcase SSL_CTRL_SET_MTU:\n#ifndef OPENSSL_NO_DTLS1\n\t\tif (larg < (long)dtls1_min_mtu())\n\t\t\treturn 0;\n#endif\n\t\tif (SSL_version(s) == DTLS1_VERSION ||\n\t\t    SSL_version(s) == DTLS1_BAD_VER)\n\t\t\t{\n\t\t\ts->d1->mtu = larg;\n\t\t\treturn larg;\n\t\t\t}\n\t\treturn 0;\n\tcase SSL_CTRL_SET_MAX_SEND_FRAGMENT:\n\t\tif (larg < 512 || larg > SSL3_RT_MAX_PLAIN_LENGTH)\n\t\t\treturn 0;\n\t\ts->max_send_fragment = larg;\n\t\treturn 1;\n\tcase SSL_CTRL_GET_RI_SUPPORT:\n\t\tif (s->s3)\n\t\t\treturn s->s3->send_connection_binding;\n\t\telse return 0;\n\tcase SSL_CTRL_CERT_FLAGS:\n\t\treturn(s->cert->cert_flags|=larg);\n\tcase SSL_CTRL_CLEAR_CERT_FLAGS:\n\t\treturn(s->cert->cert_flags &=~larg);\n\tcase SSL_CTRL_GET_RAW_CIPHERLIST:\n\t\tif (parg)\n\t\t\t{\n\t\t\tif (s->cert->ciphers_raw == NULL)\n\t\t\t\treturn 0;\n\t\t\t*(unsigned char **)parg = s->cert->ciphers_raw;\n\t\t\treturn (int)s->cert->ciphers_rawlen;\n\t\t\t}\n\t\telse\n\t\t\treturn ssl_put_cipher_by_char(s,NULL,NULL);\n\tdefault:\n\t\treturn(s->method->ssl_ctrl(s,cmd,larg,parg));\n\t\t}\n\t}', 'int SSL_SESSION_print(BIO *bp, const SSL_SESSION *x)\n\t{\n\tunsigned int i;\n\tconst char *s;\n\tif (x == NULL) goto err;\n\tif (BIO_puts(bp,"SSL-Session:\\n") <= 0) goto err;\n\tif (x->ssl_version == SSL2_VERSION)\n\t\ts="SSLv2";\n\telse if (x->ssl_version == SSL3_VERSION)\n\t\ts="SSLv3";\n\telse if (x->ssl_version == TLS1_2_VERSION)\n\t\ts="TLSv1.2";\n\telse if (x->ssl_version == TLS1_1_VERSION)\n\t\ts="TLSv1.1";\n\telse if (x->ssl_version == TLS1_VERSION)\n\t\ts="TLSv1";\n\telse if (x->ssl_version == DTLS1_VERSION)\n\t\ts="DTLSv1";\n\telse if (x->ssl_version == DTLS1_BAD_VER)\n\t\ts="DTLSv1-bad";\n\telse\n\t\ts="unknown";\n\tif (BIO_printf(bp,"    Protocol  : %s\\n",s) <= 0) goto err;\n\tif (x->cipher == NULL)\n\t\t{\n\t\tif (((x->cipher_id) & 0xff000000) == 0x02000000)\n\t\t\t{\n\t\t\tif (BIO_printf(bp,"    Cipher    : %06lX\\n",x->cipher_id&0xffffff) <= 0)\n\t\t\t\tgoto err;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tif (BIO_printf(bp,"    Cipher    : %04lX\\n",x->cipher_id&0xffff) <= 0)\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\telse\n\t\t{\n\t\tif (BIO_printf(bp,"    Cipher    : %s\\n",((x->cipher == NULL)?"unknown":x->cipher->name)) <= 0)\n\t\t\tgoto err;\n\t\t}\n\tif (BIO_puts(bp,"    Session-ID: ") <= 0) goto err;\n\tfor (i=0; i<x->session_id_length; i++)\n\t\t{\n\t\tif (BIO_printf(bp,"%02X",x->session_id[i]) <= 0) goto err;\n\t\t}\n\tif (BIO_puts(bp,"\\n    Session-ID-ctx: ") <= 0) goto err;\n\tfor (i=0; i<x->sid_ctx_length; i++)\n\t\t{\n\t\tif (BIO_printf(bp,"%02X",x->sid_ctx[i]) <= 0)\n\t\t\tgoto err;\n\t\t}\n\tif (BIO_puts(bp,"\\n    Master-Key: ") <= 0) goto err;\n\tfor (i=0; i<(unsigned int)x->master_key_length; i++)\n\t\t{\n\t\tif (BIO_printf(bp,"%02X",x->master_key[i]) <= 0) goto err;\n\t\t}\n\tif (BIO_puts(bp,"\\n    Key-Arg   : ") <= 0) goto err;\n\tif (x->key_arg_length == 0)\n\t\t{\n\t\tif (BIO_puts(bp,"None") <= 0) goto err;\n\t\t}\n\telse\n\t\tfor (i=0; i<x->key_arg_length; i++)\n\t\t\t{\n\t\t\tif (BIO_printf(bp,"%02X",x->key_arg[i]) <= 0) goto err;\n\t\t\t}\n#ifndef OPENSSL_NO_KRB5\n       if (BIO_puts(bp,"\\n    Krb5 Principal: ") <= 0) goto err;\n            if (x->krb5_client_princ_len == 0)\n            {\n\t\tif (BIO_puts(bp,"None") <= 0) goto err;\n\t\t}\n\telse\n\t\tfor (i=0; i<x->krb5_client_princ_len; i++)\n\t\t\t{\n\t\t\tif (BIO_printf(bp,"%02X",x->krb5_client_princ[i]) <= 0) goto err;\n\t\t\t}\n#endif\n#ifndef OPENSSL_NO_PSK\n\tif (BIO_puts(bp,"\\n    PSK identity: ") <= 0) goto err;\n\tif (BIO_printf(bp, "%s", x->psk_identity ? x->psk_identity : "None") <= 0) goto err;\n\tif (BIO_puts(bp,"\\n    PSK identity hint: ") <= 0) goto err;\n\tif (BIO_printf(bp, "%s", x->psk_identity_hint ? x->psk_identity_hint : "None") <= 0) goto err;\n#endif\n#ifndef OPENSSL_NO_SRP\n\tif (BIO_puts(bp,"\\n    SRP username: ") <= 0) goto err;\n\tif (BIO_printf(bp, "%s", x->srp_username ? x->srp_username : "None") <= 0) goto err;\n#endif\n#ifndef OPENSSL_NO_TLSEXT\n\tif (x->tlsext_tick_lifetime_hint)\n\t\t{\n\t\tif (BIO_printf(bp,\n\t\t\t"\\n    TLS session ticket lifetime hint: %ld (seconds)",\n\t\t\tx->tlsext_tick_lifetime_hint) <=0)\n\t\t\tgoto err;\n\t\t}\n\tif (x->tlsext_tick)\n\t\t{\n\t\tif (BIO_puts(bp, "\\n    TLS session ticket:\\n") <= 0) goto err;\n\t\tif (BIO_dump_indent(bp, (char *)x->tlsext_tick, x->tlsext_ticklen, 4) <= 0)\n\t\t\tgoto err;\n\t\t}\n#endif\n#ifndef OPENSSL_NO_COMP\n\tif (x->compress_meth != 0)\n\t\t{\n\t\tSSL_COMP *comp = NULL;\n\t\tssl_cipher_get_evp(x,NULL,NULL,NULL,NULL,&comp);\n\t\tif (comp == NULL)\n\t\t\t{\n\t\t\tif (BIO_printf(bp,"\\n    Compression: %d",x->compress_meth) <= 0) goto err;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tif (BIO_printf(bp,"\\n    Compression: %d (%s)", comp->id,comp->method->name) <= 0) goto err;\n\t\t\t}\n\t\t}\n#endif\n\tif (x->time != 0L)\n\t\t{\n\t\tif (BIO_printf(bp, "\\n    Start Time: %ld",x->time) <= 0) goto err;\n\t\t}\n\tif (x->timeout != 0L)\n\t\t{\n\t\tif (BIO_printf(bp, "\\n    Timeout   : %ld (sec)",x->timeout) <= 0) goto err;\n\t\t}\n\tif (BIO_puts(bp,"\\n") <= 0) goto err;\n\tif (BIO_puts(bp, "    Verify return code: ") <= 0) goto err;\n\tif (BIO_printf(bp, "%ld (%s)\\n", x->verify_result,\n\t\tX509_verify_cert_error_string(x->verify_result)) <= 0) goto err;\n\treturn(1);\nerr:\n\treturn(0);\n\t}', 'int X509_print(BIO *bp, X509 *x)\n{\n\treturn X509_print_ex(bp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT);\n}', 'int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)\n\t{\n\tlong l;\n\tint ret=0,i;\n\tchar *m=NULL,mlch = \' \';\n\tint nmindent = 0;\n\tX509_CINF *ci;\n\tASN1_INTEGER *bs;\n\tEVP_PKEY *pkey=NULL;\n\tconst char *neg;\n\tif((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) {\n\t\t\tmlch = \'\\n\';\n\t\t\tnmindent = 12;\n\t}\n\tif(nmflags == X509_FLAG_COMPAT)\n\t\tnmindent = 16;\n\tci=x->cert_info;\n\tif(!(cflag & X509_FLAG_NO_HEADER))\n\t\t{\n\t\tif (BIO_write(bp,"Certificate:\\n",13) <= 0) goto err;\n\t\tif (BIO_write(bp,"    Data:\\n",10) <= 0) goto err;\n\t\t}\n\tif(!(cflag & X509_FLAG_NO_VERSION))\n\t\t{\n\t\tl=X509_get_version(x);\n\t\tif (BIO_printf(bp,"%8sVersion: %lu (0x%lx)\\n","",l+1,l) <= 0) goto err;\n\t\t}\n\tif(!(cflag & X509_FLAG_NO_SERIAL))\n\t\t{\n\t\tif (BIO_write(bp,"        Serial Number:",22) <= 0) goto err;\n\t\tbs=X509_get_serialNumber(x);\n\t\tif (bs->length <= (int)sizeof(long))\n\t\t\t{\n\t\t\tl=ASN1_INTEGER_get(bs);\n\t\t\tif (bs->type == V_ASN1_NEG_INTEGER)\n\t\t\t\t{\n\t\t\t\tl= -l;\n\t\t\t\tneg="-";\n\t\t\t\t}\n\t\t\telse\n\t\t\t\tneg="";\n\t\t\tif (BIO_printf(bp," %s%lu (%s0x%lx)\\n",neg,l,neg,l) <= 0)\n\t\t\t\tgoto err;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tneg=(bs->type == V_ASN1_NEG_INTEGER)?" (Negative)":"";\n\t\t\tif (BIO_printf(bp,"\\n%12s%s","",neg) <= 0) goto err;\n\t\t\tfor (i=0; i<bs->length; i++)\n\t\t\t\t{\n\t\t\t\tif (BIO_printf(bp,"%02x%c",bs->data[i],\n\t\t\t\t\t((i+1 == bs->length)?\'\\n\':\':\')) <= 0)\n\t\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tif(!(cflag & X509_FLAG_NO_SIGNAME))\n\t\t{\n\t\tif(X509_signature_print(bp, x->sig_alg, NULL) <= 0)\n\t\t\tgoto err;\n#if 0\n\t\tif (BIO_printf(bp,"%8sSignature Algorithm: ","") <= 0)\n\t\t\tgoto err;\n\t\tif (i2a_ASN1_OBJECT(bp, ci->signature->algorithm) <= 0)\n\t\t\tgoto err;\n\t\tif (BIO_puts(bp, "\\n") <= 0)\n\t\t\tgoto err;\n#endif\n\t\t}\n\tif(!(cflag & X509_FLAG_NO_ISSUER))\n\t\t{\n\t\tif (BIO_printf(bp,"        Issuer:%c",mlch) <= 0) goto err;\n\t\tif (X509_NAME_print_ex(bp,X509_get_issuer_name(x),nmindent, nmflags) < 0) goto err;\n\t\tif (BIO_write(bp,"\\n",1) <= 0) goto err;\n\t\t}\n\tif(!(cflag & X509_FLAG_NO_VALIDITY))\n\t\t{\n\t\tif (BIO_write(bp,"        Validity\\n",17) <= 0) goto err;\n\t\tif (BIO_write(bp,"            Not Before: ",24) <= 0) goto err;\n\t\tif (!ASN1_TIME_print(bp,X509_get_notBefore(x))) goto err;\n\t\tif (BIO_write(bp,"\\n            Not After : ",25) <= 0) goto err;\n\t\tif (!ASN1_TIME_print(bp,X509_get_notAfter(x))) goto err;\n\t\tif (BIO_write(bp,"\\n",1) <= 0) goto err;\n\t\t}\n\tif(!(cflag & X509_FLAG_NO_SUBJECT))\n\t\t{\n\t\tif (BIO_printf(bp,"        Subject:%c",mlch) <= 0) goto err;\n\t\tif (X509_NAME_print_ex(bp,X509_get_subject_name(x),nmindent, nmflags) < 0) goto err;\n\t\tif (BIO_write(bp,"\\n",1) <= 0) goto err;\n\t\t}\n\tif(!(cflag & X509_FLAG_NO_PUBKEY))\n\t\t{\n\t\tif (BIO_write(bp,"        Subject Public Key Info:\\n",33) <= 0)\n\t\t\tgoto err;\n\t\tif (BIO_printf(bp,"%12sPublic Key Algorithm: ","") <= 0)\n\t\t\tgoto err;\n\t\tif (i2a_ASN1_OBJECT(bp, ci->key->algor->algorithm) <= 0)\n\t\t\tgoto err;\n\t\tif (BIO_puts(bp, "\\n") <= 0)\n\t\t\tgoto err;\n\t\tpkey=X509_get_pubkey(x);\n\t\tif (pkey == NULL)\n\t\t\t{\n\t\t\tBIO_printf(bp,"%12sUnable to load Public Key\\n","");\n\t\t\tERR_print_errors(bp);\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tEVP_PKEY_print_public(bp, pkey, 16, NULL);\n\t\t\tEVP_PKEY_free(pkey);\n\t\t\t}\n\t\t}\n\tif(!(cflag & X509_FLAG_NO_IDS))\n\t\t{\n\t\tif (ci->issuerUID)\n\t\t\t{\n\t\t\tif (BIO_printf(bp,"%8sIssuer Unique ID: ","") <= 0)\n\t\t\t\tgoto err;\n\t\t\tif (!X509_signature_dump(bp, ci->issuerUID, 12))\n\t\t\t\tgoto err;\n\t\t\t}\n\t\tif (ci->subjectUID)\n\t\t\t{\n\t\t\tif (BIO_printf(bp,"%8sSubject Unique ID: ","") <= 0)\n\t\t\t\tgoto err;\n\t\t\tif (!X509_signature_dump(bp, ci->subjectUID, 12))\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\tif (!(cflag & X509_FLAG_NO_EXTENSIONS))\n\t\tX509V3_extensions_print(bp, "X509v3 extensions",\n\t\t\t\t\tci->extensions, cflag, 8);\n\tif(!(cflag & X509_FLAG_NO_SIGDUMP))\n\t\t{\n\t\tif(X509_signature_print(bp, x->sig_alg, x->signature) <= 0) goto err;\n\t\t}\n\tif(!(cflag & X509_FLAG_NO_AUX))\n\t\t{\n\t\tif (!X509_CERT_AUX_print(bp, x->aux, 0)) goto err;\n\t\t}\n\tret=1;\nerr:\n\tif (m != NULL) OPENSSL_free(m);\n\treturn(ret);\n\t}', 'int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)\n{\n\tif(tm->type == V_ASN1_UTCTIME) return ASN1_UTCTIME_print(bp, tm);\n\tif(tm->type == V_ASN1_GENERALIZEDTIME)\n\t\t\t\treturn ASN1_GENERALIZEDTIME_print(bp, tm);\n\tBIO_write(bp,"Bad time value",14);\n\treturn(0);\n}', 'int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)\n\t{\n\tchar *v;\n\tint gmt=0;\n\tint i;\n\tint y=0,M=0,d=0,h=0,m=0,s=0;\n\tchar *f = NULL;\n\tint f_len = 0;\n\ti=tm->length;\n\tv=(char *)tm->data;\n\tif (i < 12) goto err;\n\tif (v[i-1] == \'Z\') gmt=1;\n\tfor (i=0; i<12; i++)\n\t\tif ((v[i] > \'9\') || (v[i] < \'0\')) goto err;\n\ty= (v[0]-\'0\')*1000+(v[1]-\'0\')*100 + (v[2]-\'0\')*10+(v[3]-\'0\');\n\tM= (v[4]-\'0\')*10+(v[5]-\'0\');\n\tif ((M > 12) || (M < 1)) goto err;\n\td= (v[6]-\'0\')*10+(v[7]-\'0\');\n\th= (v[8]-\'0\')*10+(v[9]-\'0\');\n\tm=  (v[10]-\'0\')*10+(v[11]-\'0\');\n\tif (tm->length >= 14 &&\n\t    (v[12] >= \'0\') && (v[12] <= \'9\') &&\n\t    (v[13] >= \'0\') && (v[13] <= \'9\'))\n\t\t{\n\t\ts=  (v[12]-\'0\')*10+(v[13]-\'0\');\n\t\tif (tm->length >= 15 && v[14] == \'.\')\n\t\t\t{\n\t\t\tint l = tm->length;\n\t\t\tf = &v[14];\n\t\t\tf_len = 1;\n\t\t\twhile (14 + f_len < l && f[f_len] >= \'0\' && f[f_len] <= \'9\')\n\t\t\t\t++f_len;\n\t\t\t}\n\t\t}\n\tif (BIO_printf(bp,"%s %2d %02d:%02d:%02d%.*s %d%s",\n\t\tmon[M-1],d,h,m,s,f_len,f,y,(gmt)?" GMT":"") <= 0)\n\t\treturn(0);\n\telse\n\t\treturn(1);\nerr:\n\tBIO_write(bp,"Bad time value",14);\n\treturn(0);\n\t}']