diff options
author | deraadt <> | 2016-08-30 11:30:14 +0000 |
---|---|---|
committer | deraadt <> | 2016-08-30 11:30:14 +0000 |
commit | e4936398d0aef967f899fc30e8022af08da108c3 (patch) | |
tree | 23f44a3decbca6a20156754c745e6fafc80120fb /src | |
parent | 250980d0e38e7e7287d2a792dfdd8462eed9e05e (diff) | |
download | openbsd-e4936398d0aef967f899fc30e8022af08da108c3.tar.gz openbsd-e4936398d0aef967f899fc30e8022af08da108c3.tar.bz2 openbsd-e4936398d0aef967f899fc30e8022af08da108c3.zip |
Fix 32-bit time handling, using time_t and make it work on systems
where that is long long.
ok beck guenther
Diffstat (limited to 'src')
-rw-r--r-- | src/usr.bin/openssl/apps.h | 3 | ||||
-rw-r--r-- | src/usr.bin/openssl/s_time.c | 46 |
2 files changed, 25 insertions, 24 deletions
diff --git a/src/usr.bin/openssl/apps.h b/src/usr.bin/openssl/apps.h index 4813fa35df..217931a4b1 100644 --- a/src/usr.bin/openssl/apps.h +++ b/src/usr.bin/openssl/apps.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: apps.h,v 1.17 2015/10/10 22:28:51 doug Exp $ */ | 1 | /* $OpenBSD: apps.h,v 1.18 2016/08/30 11:30:14 deraadt Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -310,6 +310,7 @@ struct option { | |||
310 | int (*func)(void); | 310 | int (*func)(void); |
311 | long *lvalue; | 311 | long *lvalue; |
312 | int *value; | 312 | int *value; |
313 | time_t *tvalue; | ||
313 | } opt; | 314 | } opt; |
314 | const int value; | 315 | const int value; |
315 | }; | 316 | }; |
diff --git a/src/usr.bin/openssl/s_time.c b/src/usr.bin/openssl/s_time.c index 8e6788d76d..6df03af41c 100644 --- a/src/usr.bin/openssl/s_time.c +++ b/src/usr.bin/openssl/s_time.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s_time.c,v 1.14 2015/10/17 15:00:11 doug Exp $ */ | 1 | /* $OpenBSD: s_time.c,v 1.15 2016/08/30 11:30:14 deraadt Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -86,11 +86,6 @@ | |||
86 | 86 | ||
87 | #define MYBUFSIZ 1024*8 | 87 | #define MYBUFSIZ 1024*8 |
88 | 88 | ||
89 | #undef min | ||
90 | #undef max | ||
91 | #define min(a,b) (((a) < (b)) ? (a) : (b)) | ||
92 | #define max(a,b) (((a) > (b)) ? (a) : (b)) | ||
93 | |||
94 | #define SECONDS 30 | 89 | #define SECONDS 30 |
95 | extern int verify_depth; | 90 | extern int verify_depth; |
96 | extern int verify_error; | 91 | extern int verify_error; |
@@ -110,7 +105,7 @@ struct { | |||
110 | char *cipher; | 105 | char *cipher; |
111 | char *host; | 106 | char *host; |
112 | char *keyfile; | 107 | char *keyfile; |
113 | int maxtime; | 108 | time_t maxtime; |
114 | int nbio; | 109 | int nbio; |
115 | int no_shutdown; | 110 | int no_shutdown; |
116 | int perform; | 111 | int perform; |
@@ -200,7 +195,7 @@ struct option s_time_options[] = { | |||
200 | .argname = "seconds", | 195 | .argname = "seconds", |
201 | .desc = "Duration to perform timing tests for (default 30)", | 196 | .desc = "Duration to perform timing tests for (default 30)", |
202 | .type = OPTION_ARG_INT, | 197 | .type = OPTION_ARG_INT, |
203 | .opt.value = &s_time_config.maxtime, | 198 | .opt.tvalue = &s_time_config.maxtime, |
204 | }, | 199 | }, |
205 | { | 200 | { |
206 | .name = "verify", | 201 | .name = "verify", |
@@ -253,8 +248,8 @@ s_time_main(int argc, char **argv) | |||
253 | double totalTime = 0.0; | 248 | double totalTime = 0.0; |
254 | int nConn = 0; | 249 | int nConn = 0; |
255 | SSL *scon = NULL; | 250 | SSL *scon = NULL; |
256 | long finishtime = 0; | 251 | time_t finishtime; |
257 | int ret = 1, i; | 252 | int ret = 1; |
258 | char buf[1024 * 8]; | 253 | char buf[1024 * 8]; |
259 | int ver; | 254 | int ver; |
260 | 255 | ||
@@ -329,22 +324,22 @@ s_time_main(int argc, char **argv) | |||
329 | 324 | ||
330 | if (!(s_time_config.perform & 1)) | 325 | if (!(s_time_config.perform & 1)) |
331 | goto next; | 326 | goto next; |
332 | printf("Collecting connection statistics for %d seconds\n", | 327 | printf("Collecting connection statistics for %lld seconds\n", |
333 | s_time_config.maxtime); | 328 | (long long)s_time_config.maxtime); |
334 | 329 | ||
335 | /* Loop and time how long it takes to make connections */ | 330 | /* Loop and time how long it takes to make connections */ |
336 | 331 | ||
337 | bytes_read = 0; | 332 | bytes_read = 0; |
338 | finishtime = (long) time(NULL) + s_time_config.maxtime; | 333 | finishtime = time(NULL) + s_time_config.maxtime; |
339 | tm_Time_F(START); | 334 | tm_Time_F(START); |
340 | for (;;) { | 335 | for (;;) { |
341 | if (finishtime < (long) time(NULL)) | 336 | if (finishtime < time(NULL)) |
342 | break; | 337 | break; |
343 | if ((scon = doConnection(NULL)) == NULL) | 338 | if ((scon = doConnection(NULL)) == NULL) |
344 | goto end; | 339 | goto end; |
345 | 340 | ||
346 | if (s_time_config.www_path != NULL) { | 341 | if (s_time_config.www_path != NULL) { |
347 | int retval = snprintf(buf, sizeof buf, | 342 | int i, retval = snprintf(buf, sizeof buf, |
348 | "GET %s HTTP/1.0\r\n\r\n", s_time_config.www_path); | 343 | "GET %s HTTP/1.0\r\n\r\n", s_time_config.www_path); |
349 | if ((size_t)retval >= sizeof buf) { | 344 | if ((size_t)retval >= sizeof buf) { |
350 | fprintf(stderr, "URL too long\n"); | 345 | fprintf(stderr, "URL too long\n"); |
@@ -384,9 +379,12 @@ s_time_main(int argc, char **argv) | |||
384 | } | 379 | } |
385 | totalTime += tm_Time_F(STOP); /* Add the time for this iteration */ | 380 | totalTime += tm_Time_F(STOP); /* Add the time for this iteration */ |
386 | 381 | ||
387 | i = (int) ((long) time(NULL) - finishtime + s_time_config.maxtime); | 382 | printf("\n\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\n", |
388 | printf("\n\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\n", nConn, totalTime, ((double) nConn / totalTime), bytes_read); | 383 | nConn, totalTime, ((double) nConn / totalTime), bytes_read); |
389 | printf("%d connections in %ld real seconds, %ld bytes read per connection\n", nConn, (long) time(NULL) - finishtime + s_time_config.maxtime, bytes_read / nConn); | 384 | printf("%d connections in %lld real seconds, %ld bytes read per connection\n", |
385 | nConn, | ||
386 | (long long)(time(NULL) - finishtime + s_time_config.maxtime), | ||
387 | bytes_read / nConn); | ||
390 | 388 | ||
391 | /* | 389 | /* |
392 | * Now loop and time connections using the same session id over and | 390 | * Now loop and time connections using the same session id over and |
@@ -424,20 +422,20 @@ next: | |||
424 | nConn = 0; | 422 | nConn = 0; |
425 | totalTime = 0.0; | 423 | totalTime = 0.0; |
426 | 424 | ||
427 | finishtime = (long) time(NULL) + s_time_config.maxtime; | 425 | finishtime = time(NULL) + s_time_config.maxtime; |
428 | 426 | ||
429 | printf("starting\n"); | 427 | printf("starting\n"); |
430 | bytes_read = 0; | 428 | bytes_read = 0; |
431 | tm_Time_F(START); | 429 | tm_Time_F(START); |
432 | 430 | ||
433 | for (;;) { | 431 | for (;;) { |
434 | if (finishtime < (long) time(NULL)) | 432 | if (finishtime < time(NULL)) |
435 | break; | 433 | break; |
436 | if ((doConnection(scon)) == NULL) | 434 | if ((doConnection(scon)) == NULL) |
437 | goto end; | 435 | goto end; |
438 | 436 | ||
439 | if (s_time_config.www_path) { | 437 | if (s_time_config.www_path) { |
440 | int retval = snprintf(buf, sizeof buf, | 438 | int i, retval = snprintf(buf, sizeof buf, |
441 | "GET %s HTTP/1.0\r\n\r\n", s_time_config.www_path); | 439 | "GET %s HTTP/1.0\r\n\r\n", s_time_config.www_path); |
442 | if ((size_t)retval >= sizeof buf) { | 440 | if ((size_t)retval >= sizeof buf) { |
443 | fprintf(stderr, "URL too long\n"); | 441 | fprintf(stderr, "URL too long\n"); |
@@ -474,9 +472,11 @@ next: | |||
474 | } | 472 | } |
475 | totalTime += tm_Time_F(STOP); /* Add the time for this iteration */ | 473 | totalTime += tm_Time_F(STOP); /* Add the time for this iteration */ |
476 | 474 | ||
477 | |||
478 | printf("\n\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\n", nConn, totalTime, ((double) nConn / totalTime), bytes_read); | 475 | printf("\n\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\n", nConn, totalTime, ((double) nConn / totalTime), bytes_read); |
479 | printf("%d connections in %ld real seconds, %ld bytes read per connection\n", nConn, (long) time(NULL) - finishtime + s_time_config.maxtime, bytes_read / nConn); | 476 | printf("%d connections in %lld real seconds, %ld bytes read per connection\n", |
477 | nConn, | ||
478 | (long long)(time(NULL) - finishtime + s_time_config.maxtime), | ||
479 | bytes_read / nConn); | ||
480 | 480 | ||
481 | ret = 0; | 481 | ret = 0; |
482 | end: | 482 | end: |