diff options
author | deraadt <> | 2017-04-18 02:15:50 +0000 |
---|---|---|
committer | deraadt <> | 2017-04-18 02:15:50 +0000 |
commit | d1b012a5aa610c2a77715ea628538867362a322a (patch) | |
tree | 94592c42f2d7070c569ac2d452a15695d8551ab8 | |
parent | 0cb12ace14f001cd3e42cd8bfffe9903ffc74412 (diff) | |
download | openbsd-d1b012a5aa610c2a77715ea628538867362a322a.tar.gz openbsd-d1b012a5aa610c2a77715ea628538867362a322a.tar.bz2 openbsd-d1b012a5aa610c2a77715ea628538867362a322a.zip |
use freezero() instead of 4-line conditional explicit_bzero + free
-rw-r--r-- | src/usr.bin/openssl/apps.c | 7 | ||||
-rw-r--r-- | src/usr.bin/openssl/dgst.c | 7 | ||||
-rw-r--r-- | src/usr.bin/openssl/s_client.c | 17 | ||||
-rw-r--r-- | src/usr.bin/openssl/s_server.c | 7 |
4 files changed, 10 insertions, 28 deletions
diff --git a/src/usr.bin/openssl/apps.c b/src/usr.bin/openssl/apps.c index c6c992fe10..7594e77c19 100644 --- a/src/usr.bin/openssl/apps.c +++ b/src/usr.bin/openssl/apps.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: apps.c,v 1.42 2017/01/21 09:29:09 deraadt Exp $ */ | 1 | /* $OpenBSD: apps.c,v 1.43 2017/04/18 02:15:50 deraadt Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -397,10 +397,7 @@ password_callback(char *buf, int bufsiz, int verify, void *arg) | |||
397 | } while (ok < 0 && | 397 | } while (ok < 0 && |
398 | UI_ctrl(ui, UI_CTRL_IS_REDOABLE, 0, 0, 0)); | 398 | UI_ctrl(ui, UI_CTRL_IS_REDOABLE, 0, 0, 0)); |
399 | 399 | ||
400 | if (buff) { | 400 | freezero(buff, (unsigned int) bufsiz); |
401 | explicit_bzero(buff, (unsigned int) bufsiz); | ||
402 | free(buff); | ||
403 | } | ||
404 | if (ok >= 0) | 401 | if (ok >= 0) |
405 | res = strlen(buf); | 402 | res = strlen(buf); |
406 | if (ok == -1) { | 403 | if (ok == -1) { |
diff --git a/src/usr.bin/openssl/dgst.c b/src/usr.bin/openssl/dgst.c index ce50e08b53..bcc9f1c761 100644 --- a/src/usr.bin/openssl/dgst.c +++ b/src/usr.bin/openssl/dgst.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dgst.c,v 1.10 2017/01/20 08:57:11 deraadt Exp $ */ | 1 | /* $OpenBSD: dgst.c,v 1.11 2017/04/18 02:15:50 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 | * |
@@ -448,10 +448,7 @@ mac_end: | |||
448 | } | 448 | } |
449 | 449 | ||
450 | end: | 450 | end: |
451 | if (buf != NULL) { | 451 | freezero(buf, BUFSIZE); |
452 | explicit_bzero(buf, BUFSIZE); | ||
453 | free(buf); | ||
454 | } | ||
455 | if (in != NULL) | 452 | if (in != NULL) |
456 | BIO_free(in); | 453 | BIO_free(in); |
457 | free(passin); | 454 | free(passin); |
diff --git a/src/usr.bin/openssl/s_client.c b/src/usr.bin/openssl/s_client.c index 4a0a832c12..aa1c5764bd 100644 --- a/src/usr.bin/openssl/s_client.c +++ b/src/usr.bin/openssl/s_client.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s_client.c,v 1.31 2017/01/24 09:07:40 jsing Exp $ */ | 1 | /* $OpenBSD: s_client.c,v 1.32 2017/04/18 02:15:50 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 | * |
@@ -1266,18 +1266,9 @@ end: | |||
1266 | free(pass); | 1266 | free(pass); |
1267 | if (vpm) | 1267 | if (vpm) |
1268 | X509_VERIFY_PARAM_free(vpm); | 1268 | X509_VERIFY_PARAM_free(vpm); |
1269 | if (cbuf != NULL) { | 1269 | freezero(cbuf, BUFSIZZ); |
1270 | explicit_bzero(cbuf, BUFSIZZ); | 1270 | freezero(sbuf, BUFSIZZ); |
1271 | free(cbuf); | 1271 | freezero(mbuf, BUFSIZZ); |
1272 | } | ||
1273 | if (sbuf != NULL) { | ||
1274 | explicit_bzero(sbuf, BUFSIZZ); | ||
1275 | free(sbuf); | ||
1276 | } | ||
1277 | if (mbuf != NULL) { | ||
1278 | explicit_bzero(mbuf, BUFSIZZ); | ||
1279 | free(mbuf); | ||
1280 | } | ||
1281 | if (bio_c_out != NULL) { | 1272 | if (bio_c_out != NULL) { |
1282 | BIO_free(bio_c_out); | 1273 | BIO_free(bio_c_out); |
1283 | bio_c_out = NULL; | 1274 | bio_c_out = NULL; |
diff --git a/src/usr.bin/openssl/s_server.c b/src/usr.bin/openssl/s_server.c index d73a11799b..493dc26264 100644 --- a/src/usr.bin/openssl/s_server.c +++ b/src/usr.bin/openssl/s_server.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s_server.c,v 1.25 2017/01/20 08:57:12 deraadt Exp $ */ | 1 | /* $OpenBSD: s_server.c,v 1.26 2017/04/18 02:15:50 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 | * |
@@ -1590,10 +1590,7 @@ err: | |||
1590 | SSL_free(con); | 1590 | SSL_free(con); |
1591 | } | 1591 | } |
1592 | BIO_printf(bio_s_out, "CONNECTION CLOSED\n"); | 1592 | BIO_printf(bio_s_out, "CONNECTION CLOSED\n"); |
1593 | if (buf != NULL) { | 1593 | freezero(buf, bufsize); |
1594 | explicit_bzero(buf, bufsize); | ||
1595 | free(buf); | ||
1596 | } | ||
1597 | if (ret >= 0) | 1594 | if (ret >= 0) |
1598 | BIO_printf(bio_s_out, "ACCEPT\n"); | 1595 | BIO_printf(bio_s_out, "ACCEPT\n"); |
1599 | return (ret); | 1596 | return (ret); |