diff options
author | David Benjamin <davidben@google.com> | 2024-02-04 23:27:14 -0500 |
---|---|---|
committer | Boringssl LUCI CQ <boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2024-02-23 11:08:04 +0000 |
commit | cadebfd6398e017addaae4878662aadb42f60bda (patch) | |
tree | 1f8a324a8c22fcbe8d0abdd3920781774a43299c /include | |
parent | ab4037e3d14b2b1e02c93f76d80a8dd0ce3193fc (diff) | |
download | boringssl-cadebfd6398e017addaae4878662aadb42f60bda.zip boringssl-cadebfd6398e017addaae4878662aadb42f60bda.tar.gz boringssl-cadebfd6398e017addaae4878662aadb42f60bda.tar.bz2 |
Consistently open files in binary mode on Windows
BIO_*_filename, in upstream OpenSSL, opens in binary mode on Windows,
not text mode. We seem to have lost those ifdefs in the fork. But since
C mandates the 'b' suffix (POSIX just ignores it), apply it consistently
to all OSes for simplicity.
This fixes X509_FILETYPE_ASN1 in X509_STORE's file-based machinery on
Windows.
Also fix the various BIO_new_file calls to all specify binary mode.
Looking through them, I don't think any of them care (they're all
parsing PEM), but let's just apply it across the board so we don't have
to think about this.
Update-Note: BIO_read_filename, etc., now open in binary mode on
Windows. This matches OpenSSL behavior.
Change-Id: I7e555085d5c66ad2f205b476d0317570075bbadb
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/66009
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/openssl/bio.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/include/openssl/bio.h b/include/openssl/bio.h index 33b020b..93f3c0c 100644 --- a/include/openssl/bio.h +++ b/include/openssl/bio.h @@ -492,22 +492,26 @@ OPENSSL_EXPORT int BIO_set_fp(BIO *bio, FILE *file, int close_flag); // BIO_read_filename opens |filename| for reading and sets the result as the // |FILE| for |bio|. It returns one on success and zero otherwise. The |FILE| -// will be closed when |bio| is freed. +// will be closed when |bio| is freed. On Windows, the file is opened in binary +// mode. OPENSSL_EXPORT int BIO_read_filename(BIO *bio, const char *filename); // BIO_write_filename opens |filename| for writing and sets the result as the // |FILE| for |bio|. It returns one on success and zero otherwise. The |FILE| -// will be closed when |bio| is freed. +// will be closed when |bio| is freed. On Windows, the file is opened in binary +// mode. OPENSSL_EXPORT int BIO_write_filename(BIO *bio, const char *filename); // BIO_append_filename opens |filename| for appending and sets the result as // the |FILE| for |bio|. It returns one on success and zero otherwise. The -// |FILE| will be closed when |bio| is freed. +// |FILE| will be closed when |bio| is freed. On Windows, the file is opened in +// binary mode. OPENSSL_EXPORT int BIO_append_filename(BIO *bio, const char *filename); // BIO_rw_filename opens |filename| for reading and writing and sets the result // as the |FILE| for |bio|. It returns one on success and zero otherwise. The -// |FILE| will be closed when |bio| is freed. +// |FILE| will be closed when |bio| is freed. On Windows, the file is opened in +// binary mode. OPENSSL_EXPORT int BIO_rw_filename(BIO *bio, const char *filename); // BIO_tell returns the file offset of |bio|, or a negative number on error or |