openssl s_time: check for SSL_write failure

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

openssl s_time: check for SSL_write failure

Scott Cheloha
Check for failure.

Also reuse retval for the buffer length in lieu of strlen.

ok?

Index: s_time.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/s_time.c,v
retrieving revision 1.29
diff -u -p -r1.29 s_time.c
--- s_time.c 22 Aug 2018 20:36:24 -0000 1.29
+++ s_time.c 22 Aug 2018 22:08:54 -0000
@@ -380,7 +380,8 @@ run_test(SSL *scon)
  fprintf(stderr, "URL too long\n");
  return 0;
  }
- SSL_write(scon, buf, strlen(buf));
+ if (SSL_write(scon, buf, retval) <= 0)
+ return 0;
  while ((i = SSL_read(scon, buf, sizeof(buf))) > 0)
  bytes_read += i;
  }

Reply | Threaded
Open this post in threaded view
|

Re: openssl s_time: check for SSL_write failure

Jeremie Courreges-Anglas-2
On Wed, Aug 22 2018, Scott Cheloha <[hidden email]> wrote:
> Check for failure.
>
> Also reuse retval for the buffer length in lieu of strlen.
>
> ok?

Glancing at SSL_write(3), shouldn't this code loop if we get an error
and SSL_get_error(3) returns SSL_ERROR_WANT_READ or
SSL_ERROR_WANT_WRITE?  Or perhaps it should just set
SSL_MODE_AUTO_RETRY?

> Index: s_time.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/openssl/s_time.c,v
> retrieving revision 1.29
> diff -u -p -r1.29 s_time.c
> --- s_time.c 22 Aug 2018 20:36:24 -0000 1.29
> +++ s_time.c 22 Aug 2018 22:08:54 -0000
> @@ -380,7 +380,8 @@ run_test(SSL *scon)
>   fprintf(stderr, "URL too long\n");
>   return 0;
>   }
> - SSL_write(scon, buf, strlen(buf));
> + if (SSL_write(scon, buf, retval) <= 0)
> + return 0;
>   while ((i = SSL_read(scon, buf, sizeof(buf))) > 0)
>   bytes_read += i;
>   }
>

--
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE