diff options
| author | deraadt <> | 2015-04-11 16:03:21 +0000 |
|---|---|---|
| committer | deraadt <> | 2015-04-11 16:03:21 +0000 |
| commit | 3f6d0024da68bdf5d0f128537ac3ed536e6e6a6c (patch) | |
| tree | 02ee416418c40719cf48cd968d4b546afbaf642a /src/lib/libcrypto/x509 | |
| parent | 0a2c31c8f577b7611e81418bbe11b6a748f005ca (diff) | |
| download | openbsd-3f6d0024da68bdf5d0f128537ac3ed536e6e6a6c.tar.gz openbsd-3f6d0024da68bdf5d0f128537ac3ed536e6e6a6c.tar.bz2 openbsd-3f6d0024da68bdf5d0f128537ac3ed536e6e6a6c.zip | |
Remove all getenv() calls, especially those wrapped by issetugid().
getenv()'s wrapped by issetugid() are safe, but issetugid() is correct
difficult to impliment on many operating systems. By accident, a grand
experiment was run over the last year, where issetugid() returned 1 (the
safe value) on a few operating systems. Noone noticed & complained that
certain environment variables were not working.......
ok doug beck jsing, discussion with others
Diffstat (limited to 'src/lib/libcrypto/x509')
| -rw-r--r-- | src/lib/libcrypto/x509/by_dir.c | 12 | ||||
| -rw-r--r-- | src/lib/libcrypto/x509/by_file.c | 16 | ||||
| -rw-r--r-- | src/lib/libcrypto/x509/x509_vfy.c | 8 |
3 files changed, 8 insertions, 28 deletions
diff --git a/src/lib/libcrypto/x509/by_dir.c b/src/lib/libcrypto/x509/by_dir.c index 032210424d..7b7d14a950 100644 --- a/src/lib/libcrypto/x509/by_dir.c +++ b/src/lib/libcrypto/x509/by_dir.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: by_dir.c,v 1.36 2015/02/12 03:54:07 jsing Exp $ */ | 1 | /* $OpenBSD: by_dir.c,v 1.37 2015/04/11 16:03:21 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 | * |
| @@ -124,20 +124,14 @@ dir_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl, | |||
| 124 | { | 124 | { |
| 125 | int ret = 0; | 125 | int ret = 0; |
| 126 | BY_DIR *ld; | 126 | BY_DIR *ld; |
| 127 | char *dir = NULL; | ||
| 128 | 127 | ||
| 129 | ld = (BY_DIR *)ctx->method_data; | 128 | ld = (BY_DIR *)ctx->method_data; |
| 130 | 129 | ||
| 131 | switch (cmd) { | 130 | switch (cmd) { |
| 132 | case X509_L_ADD_DIR: | 131 | case X509_L_ADD_DIR: |
| 133 | if (argl == X509_FILETYPE_DEFAULT) { | 132 | if (argl == X509_FILETYPE_DEFAULT) { |
| 134 | if (issetugid() == 0) | 133 | ret = add_cert_dir(ld, X509_get_default_cert_dir(), |
| 135 | dir = getenv(X509_get_default_cert_dir_env()); | 134 | X509_FILETYPE_PEM); |
| 136 | if (dir) | ||
| 137 | ret = add_cert_dir(ld, dir, X509_FILETYPE_PEM); | ||
| 138 | else | ||
| 139 | ret = add_cert_dir(ld, X509_get_default_cert_dir(), | ||
| 140 | X509_FILETYPE_PEM); | ||
| 141 | if (!ret) { | 135 | if (!ret) { |
| 142 | X509err(X509_F_DIR_CTRL, X509_R_LOADING_CERT_DIR); | 136 | X509err(X509_F_DIR_CTRL, X509_R_LOADING_CERT_DIR); |
| 143 | } | 137 | } |
diff --git a/src/lib/libcrypto/x509/by_file.c b/src/lib/libcrypto/x509/by_file.c index 91a8e781b2..68920271fc 100644 --- a/src/lib/libcrypto/x509/by_file.c +++ b/src/lib/libcrypto/x509/by_file.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: by_file.c,v 1.18 2015/02/05 01:33:22 reyk Exp $ */ | 1 | /* $OpenBSD: by_file.c,v 1.19 2015/04/11 16:03:21 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 | * |
| @@ -94,21 +94,13 @@ by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl, | |||
| 94 | char **ret) | 94 | char **ret) |
| 95 | { | 95 | { |
| 96 | int ok = 0; | 96 | int ok = 0; |
| 97 | char *file = NULL; | ||
| 98 | 97 | ||
| 99 | switch (cmd) { | 98 | switch (cmd) { |
| 100 | case X509_L_FILE_LOAD: | 99 | case X509_L_FILE_LOAD: |
| 101 | if (argl == X509_FILETYPE_DEFAULT) { | 100 | if (argl == X509_FILETYPE_DEFAULT) { |
| 102 | if (issetugid() == 0) | 101 | ok = (X509_load_cert_crl_file(ctx, |
| 103 | file = getenv(X509_get_default_cert_file_env()); | 102 | X509_get_default_cert_file(), |
| 104 | if (file) | 103 | X509_FILETYPE_PEM) != 0); |
| 105 | ok = (X509_load_cert_crl_file(ctx, file, | ||
| 106 | X509_FILETYPE_PEM) != 0); | ||
| 107 | else | ||
| 108 | ok = (X509_load_cert_crl_file(ctx, | ||
| 109 | X509_get_default_cert_file(), | ||
| 110 | X509_FILETYPE_PEM) != 0); | ||
| 111 | |||
| 112 | if (!ok) { | 104 | if (!ok) { |
| 113 | X509err(X509_F_BY_FILE_CTRL, | 105 | X509err(X509_F_BY_FILE_CTRL, |
| 114 | X509_R_LOADING_DEFAULTS); | 106 | X509_R_LOADING_DEFAULTS); |
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c index c383fda4f2..442035625a 100644 --- a/src/lib/libcrypto/x509/x509_vfy.c +++ b/src/lib/libcrypto/x509/x509_vfy.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: x509_vfy.c,v 1.40 2015/02/11 02:17:59 jsing Exp $ */ | 1 | /* $OpenBSD: x509_vfy.c,v 1.41 2015/04/11 16:03:21 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 | * |
| @@ -483,12 +483,6 @@ check_chain_extensions(X509_STORE_CTX *ctx) | |||
| 483 | } else { | 483 | } else { |
| 484 | allow_proxy_certs = | 484 | allow_proxy_certs = |
| 485 | !!(ctx->param->flags & X509_V_FLAG_ALLOW_PROXY_CERTS); | 485 | !!(ctx->param->flags & X509_V_FLAG_ALLOW_PROXY_CERTS); |
| 486 | #if 0 | ||
| 487 | /* A hack to keep people who don't want to modify their | ||
| 488 | software happy */ | ||
| 489 | if (issetugid() == 0 && getenv("OPENSSL_ALLOW_PROXY_CERTS")) | ||
| 490 | allow_proxy_certs = 1; | ||
| 491 | #endif | ||
| 492 | purpose = ctx->param->purpose; | 486 | purpose = ctx->param->purpose; |
| 493 | } | 487 | } |
| 494 | 488 | ||
