openssl s_time: don't fail by default in -new case

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

openssl s_time: don't fail by default in -new case

Scott Cheloha
This is a fun one.  When you run

        openssl s_time -connect host:port -new

it exits with status 1, even if nothing fails, because we 'goto end'
without setting ret = 0 in the -new case.

Present since the SSLeay 0.8.1b import into the OpenSSL tree [1].
A seasoned bug. :)

ok?

--
Scott Cheloha

[1] https://github.com/openssl/openssl/blob/d02b48c63a58ea4367a0e905979f140b7d090f86/apps/s_time.c

Index: usr.bin/openssl/s_time.c
===================================================================
RCS file: /cvs/src/usr.bin/openssl/s_time.c,v
retrieving revision 1.25
diff -u -p -r1.25 s_time.c
--- usr.bin/openssl/s_time.c 11 Aug 2018 16:07:36 -0000 1.25
+++ usr.bin/openssl/s_time.c 13 Aug 2018 16:46:57 -0000
@@ -316,29 +316,22 @@ s_time_main(int argc, char **argv)
  /* goto end; */
  }
 
- if (!(s_time_config.perform & 1))
- goto next;
- printf("Collecting connection statistics for %lld seconds\n",
-    (long long)s_time_config.maxtime);
-
  /* Loop and time how long it takes to make connections */
-
- if (benchmark(0))
- goto end;
-
+ if (s_time_config.perform & 1) {
+ printf("Collecting connection statistics for %lld seconds\n",
+    (long long)s_time_config.maxtime);
+ if (benchmark(0))
+ goto end;
+ }
  /*
  * Now loop and time connections using the same session id over and
  * over
  */
-
- next:
- if (!(s_time_config.perform & 2))
- goto end;
- printf("\n\nNow timing with session id reuse.\n");
-
- if (benchmark(1))
- goto end;
-
+ if (s_time_config.perform & 2) {
+ printf("\n\nNow timing with session id reuse.\n");
+ if (benchmark(1))
+ goto end;
+ }
  ret = 0;
  end:
  if (tm_ctx != NULL) {

Reply | Threaded
Open this post in threaded view
|

Re: openssl s_time: don't fail by default in -new case

Theo Buehler-5
On Mon, Aug 13, 2018 at 11:59:56AM -0500, Scott Cheloha wrote:

> This is a fun one.  When you run
>
> openssl s_time -connect host:port -new
>
> it exits with status 1, even if nothing fails, because we 'goto end'
> without setting ret = 0 in the -new case.
>
> Present since the SSLeay 0.8.1b import into the OpenSSL tree [1].
> A seasoned bug. :)
>
> ok?

ok tb

>
> --
> Scott Cheloha
>
> [1] https://github.com/openssl/openssl/blob/d02b48c63a58ea4367a0e905979f140b7d090f86/apps/s_time.c
>
> Index: usr.bin/openssl/s_time.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/openssl/s_time.c,v
> retrieving revision 1.25
> diff -u -p -r1.25 s_time.c
> --- usr.bin/openssl/s_time.c 11 Aug 2018 16:07:36 -0000 1.25
> +++ usr.bin/openssl/s_time.c 13 Aug 2018 16:46:57 -0000
> @@ -316,29 +316,22 @@ s_time_main(int argc, char **argv)
>   /* goto end; */
>   }
>  
> - if (!(s_time_config.perform & 1))
> - goto next;
> - printf("Collecting connection statistics for %lld seconds\n",
> -    (long long)s_time_config.maxtime);
> -
>   /* Loop and time how long it takes to make connections */
> -
> - if (benchmark(0))
> - goto end;
> -
> + if (s_time_config.perform & 1) {
> + printf("Collecting connection statistics for %lld seconds\n",
> +    (long long)s_time_config.maxtime);
> + if (benchmark(0))
> + goto end;
> + }
>   /*
>   * Now loop and time connections using the same session id over and
>   * over
>   */
> -
> - next:
> - if (!(s_time_config.perform & 2))
> - goto end;
> - printf("\n\nNow timing with session id reuse.\n");
> -
> - if (benchmark(1))
> - goto end;
> -
> + if (s_time_config.perform & 2) {
> + printf("\n\nNow timing with session id reuse.\n");
> + if (benchmark(1))
> + goto end;
> + }
>   ret = 0;
>   end:
>   if (tm_ctx != NULL) {

Reply | Threaded
Open this post in threaded view
|

Re: openssl s_time: don't fail by default in -new case

Jeremie Courreges-Anglas-2
In reply to this post by Scott Cheloha
On Mon, Aug 13 2018, Scott Cheloha <[hidden email]> wrote:

> This is a fun one.  When you run
>
> openssl s_time -connect host:port -new
>
> it exits with status 1, even if nothing fails, because we 'goto end'
> without setting ret = 0 in the -new case.
>
> Present since the SSLeay 0.8.1b import into the OpenSSL tree [1].
> A seasoned bug. :)
>
> ok?

ok jca@

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