n=ctx->tmp_len; if (n < 3)
if (ctx->tmp_len < 3)
static int b64_write(BIO *b, const char *in, int inl)	{	int ret=inl,n,i;	BIO_B64_CTX *ctx;	ctx=(BIO_B64_CTX *)b->ptr;	BIO_clear_retry_flags(b);	if (ctx->encode != B64_ENCODE)		{		ctx->encode=B64_ENCODE;		ctx->buf_len=0;		ctx->buf_off=0;		ctx->tmp_len=0;		EVP_EncodeInit(&(ctx->base64));		}	n=ctx->buf_len-ctx->buf_off;	while (n > 0)		{		i=BIO_write(b->next_bio,&(ctx->buf[ctx->buf_off]),n);		if (i <= 0)			{			BIO_copy_next_retry(b);			return(i);			}		ctx->buf_off+=i;		n-=i;		}	/* at this point all pending data has been written */	if ((in == NULL) || (inl <= 0)) return(0);	ctx->buf_off=0;	while (inl > 0)		{		n=(inl > B64_BLOCK_SIZE)?B64_BLOCK_SIZE:inl;		if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL)			{			if (ctx->tmp_len > 0)				{				n=3-ctx->tmp_len;				memcpy(&(ctx->tmp[ctx->tmp_len]),in,n);				ctx->tmp_len+=n;				n=ctx->tmp_len;				if (n < 3)					break;				ctx->buf_len=EVP_EncodeBlock(					(unsigned char *)ctx->buf,					(unsigned char *)ctx->tmp,n);				}			else				{				if (n < 3)					{					memcpy(&(ctx->tmp[0]),in,n);					ctx->tmp_len=n;					break;					}				n-=n%3;				ctx->buf_len=EVP_EncodeBlock(					(unsigned char *)ctx->buf,					(unsigned char *)in,n);				}			}		else			{			EVP_EncodeUpdate(&(ctx->base64),				(unsigned char *)ctx->buf,&ctx->buf_len,				(unsigned char *)in,n);			}		inl-=n;		in+=n;		ctx->buf_off=0;		n=ctx->buf_len;		while (n > 0)			{			i=BIO_write(b->next_bio,&(ctx->buf[ctx->buf_off]),n);			if (i <= 0)				{				BIO_copy_next_retry(b);				return((ret == 0)?i:ret);				}			n-=i;			ctx->buf_off+=i;			}		ctx->buf_len=0;		ctx->buf_off=0;		}	return(ret);	}