[OpenWrt-Devel] [PATCH] [ustream-ssl] polarssl: fix long writes

Luka Perkov luka at openwrt.org
Sat Apr 11 17:38:47 EDT 2015


On Sat, Apr 11, 2015 at 11:36:14PM +0200, Felix Fietkau wrote:
> On 2015-04-11 23:23, Luka Perkov wrote:
> > Enable to write more data then defined in SSL_MAX_CONTENT_LEN.
> > 
> > Signed-off-by: Luka Perkov <luka at openwrt.org>
> > ---
> >  ustream-polarssl.c | 18 ++++++++++++------
> >  1 file changed, 12 insertions(+), 6 deletions(-)
> > 
> > diff --git a/ustream-polarssl.c b/ustream-polarssl.c
> > index cbf24cb..ce9b164 100644
> > --- a/ustream-polarssl.c
> > +++ b/ustream-polarssl.c
> > @@ -232,14 +232,20 @@ __hidden enum ssl_conn_status __ustream_ssl_connect(struct ustream_ssl *us)
> >  __hidden int __ustream_ssl_write(struct ustream_ssl *us, const char *buf, int len)
> >  {
> >  	void *ssl = us->ssl;
> > -	int ret = ssl_write(ssl, (const unsigned char *) buf, len);
> > +	int done = 0, ret = 0;
> >  
> > -	if (ret < 0) {
> > -		if (ssl_do_wait(ret))
> > -			return 0;
> > +	while (done != len) {
> > +		ret = ssl_write(ssl, (const unsigned char *) buf + done, len - done);
> >  
> > -		ustream_ssl_error(us, ret);
> > -		return -1;
> > +		if (ret < 0) {
> > +			if (ssl_do_wait(ret))
> > +				return 0;
> This does not look right. I think it should be 'return done', otherwise
> plaintext data will be duplicated if the first write succeeds but the
> second doesn't.

Yes, this one too... I've sent v2 with other return fixed. Going to send
v3 in a bit.

Luka
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list