diff options
author | miod <> | 2014-11-11 19:26:12 +0000 |
---|---|---|
committer | miod <> | 2014-11-11 19:26:12 +0000 |
commit | d5d66be1773c61bef0ccd90c53054a490f638407 (patch) | |
tree | 9e0e423d0598031457055e129f40fb612f4f0b07 /src | |
parent | 196bc8bde22c57764fd6fd65e48c48dd559664ce (diff) | |
download | openbsd-d5d66be1773c61bef0ccd90c53054a490f638407.tar.gz openbsd-d5d66be1773c61bef0ccd90c53054a490f638407.tar.bz2 openbsd-d5d66be1773c61bef0ccd90c53054a490f638407.zip |
f{read,write} take a number of items and an item size as arguments, and
return the number of items read of written.
When you intend to return the number of bytes actually processed, it is
wise to pass 1 as the item size and the size as the number of items.
But in *some* places, the OpenSSL does the opposite, and has extra logic
to change a successful return of 1 (item processed) into the real size.
And, guess why it does that? Because of old VMS, for they (used to) have a
substandard stdio implementation.
Note that this change causes the return values of BIO_dump_fp() and
BIO_dump_indent_fp() to no longer be useless (actual number of callback calls),
but actual bytes output. Given the irrelevance of the return value before,
it is unlikely that anything depends upon it (and if something does, it
probably has other problems in need for a fix...)
ok tedu@ beck@ jsing@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/bio/b_dump.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/bio/bss_file.c | 17 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/bio/b_dump.c | 4 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/bio/bss_file.c | 17 |
4 files changed, 14 insertions, 28 deletions
diff --git a/src/lib/libcrypto/bio/b_dump.c b/src/lib/libcrypto/bio/b_dump.c index 91979bd755..0943e9006d 100644 --- a/src/lib/libcrypto/bio/b_dump.c +++ b/src/lib/libcrypto/bio/b_dump.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: b_dump.c,v 1.19 2014/07/11 08:44:47 jsing Exp $ */ | 1 | /* $OpenBSD: b_dump.c,v 1.20 2014/11/11 19:26:12 miod 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 | * |
@@ -149,7 +149,7 @@ BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), | |||
149 | static int | 149 | static int |
150 | write_fp(const void *data, size_t len, void *fp) | 150 | write_fp(const void *data, size_t len, void *fp) |
151 | { | 151 | { |
152 | return fwrite(data, len, 1, fp); | 152 | return fwrite(data, 1, len, fp); |
153 | } | 153 | } |
154 | 154 | ||
155 | int | 155 | int |
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c index 4fa3fb6062..c710076fea 100644 --- a/src/lib/libcrypto/bio/bss_file.c +++ b/src/lib/libcrypto/bio/bss_file.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bss_file.c,v 1.30 2014/07/11 08:44:47 jsing Exp $ */ | 1 | /* $OpenBSD: bss_file.c,v 1.31 2014/11/11 19:26:12 miod 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 | * |
@@ -185,8 +185,8 @@ file_read(BIO *b, char *out, int outl) | |||
185 | { | 185 | { |
186 | int ret = 0; | 186 | int ret = 0; |
187 | 187 | ||
188 | if (b->init && (out != NULL)) { | 188 | if (b->init && out != NULL) { |
189 | ret = fread(out, 1,(int)outl,(FILE *)b->ptr); | 189 | ret = fread(out, 1, outl, (FILE *)b->ptr); |
190 | if (ret == 0 && ferror((FILE *)b->ptr)) { | 190 | if (ret == 0 && ferror((FILE *)b->ptr)) { |
191 | SYSerr(SYS_F_FREAD, errno); | 191 | SYSerr(SYS_F_FREAD, errno); |
192 | BIOerr(BIO_F_FILE_READ, ERR_R_SYS_LIB); | 192 | BIOerr(BIO_F_FILE_READ, ERR_R_SYS_LIB); |
@@ -201,15 +201,8 @@ file_write(BIO *b, const char *in, int inl) | |||
201 | { | 201 | { |
202 | int ret = 0; | 202 | int ret = 0; |
203 | 203 | ||
204 | if (b->init && (in != NULL)) { | 204 | if (b->init && in != NULL) |
205 | ret = fwrite(in,(int)inl, 1,(FILE *)b->ptr); | 205 | ret = fwrite(in, 1, inl, (FILE *)b->ptr); |
206 | if (ret) | ||
207 | ret = inl; | ||
208 | /* ret=fwrite(in,1,(int)inl,(FILE *)b->ptr); */ | ||
209 | /* according to Tim Hudson <tjh@cryptsoft.com>, the commented | ||
210 | * out version above can cause 'inl' write calls under | ||
211 | * some stupid stdio implementations (VMS) */ | ||
212 | } | ||
213 | return (ret); | 206 | return (ret); |
214 | } | 207 | } |
215 | 208 | ||
diff --git a/src/lib/libssl/src/crypto/bio/b_dump.c b/src/lib/libssl/src/crypto/bio/b_dump.c index 91979bd755..0943e9006d 100644 --- a/src/lib/libssl/src/crypto/bio/b_dump.c +++ b/src/lib/libssl/src/crypto/bio/b_dump.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: b_dump.c,v 1.19 2014/07/11 08:44:47 jsing Exp $ */ | 1 | /* $OpenBSD: b_dump.c,v 1.20 2014/11/11 19:26:12 miod 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 | * |
@@ -149,7 +149,7 @@ BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), | |||
149 | static int | 149 | static int |
150 | write_fp(const void *data, size_t len, void *fp) | 150 | write_fp(const void *data, size_t len, void *fp) |
151 | { | 151 | { |
152 | return fwrite(data, len, 1, fp); | 152 | return fwrite(data, 1, len, fp); |
153 | } | 153 | } |
154 | 154 | ||
155 | int | 155 | int |
diff --git a/src/lib/libssl/src/crypto/bio/bss_file.c b/src/lib/libssl/src/crypto/bio/bss_file.c index 4fa3fb6062..c710076fea 100644 --- a/src/lib/libssl/src/crypto/bio/bss_file.c +++ b/src/lib/libssl/src/crypto/bio/bss_file.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bss_file.c,v 1.30 2014/07/11 08:44:47 jsing Exp $ */ | 1 | /* $OpenBSD: bss_file.c,v 1.31 2014/11/11 19:26:12 miod 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 | * |
@@ -185,8 +185,8 @@ file_read(BIO *b, char *out, int outl) | |||
185 | { | 185 | { |
186 | int ret = 0; | 186 | int ret = 0; |
187 | 187 | ||
188 | if (b->init && (out != NULL)) { | 188 | if (b->init && out != NULL) { |
189 | ret = fread(out, 1,(int)outl,(FILE *)b->ptr); | 189 | ret = fread(out, 1, outl, (FILE *)b->ptr); |
190 | if (ret == 0 && ferror((FILE *)b->ptr)) { | 190 | if (ret == 0 && ferror((FILE *)b->ptr)) { |
191 | SYSerr(SYS_F_FREAD, errno); | 191 | SYSerr(SYS_F_FREAD, errno); |
192 | BIOerr(BIO_F_FILE_READ, ERR_R_SYS_LIB); | 192 | BIOerr(BIO_F_FILE_READ, ERR_R_SYS_LIB); |
@@ -201,15 +201,8 @@ file_write(BIO *b, const char *in, int inl) | |||
201 | { | 201 | { |
202 | int ret = 0; | 202 | int ret = 0; |
203 | 203 | ||
204 | if (b->init && (in != NULL)) { | 204 | if (b->init && in != NULL) |
205 | ret = fwrite(in,(int)inl, 1,(FILE *)b->ptr); | 205 | ret = fwrite(in, 1, inl, (FILE *)b->ptr); |
206 | if (ret) | ||
207 | ret = inl; | ||
208 | /* ret=fwrite(in,1,(int)inl,(FILE *)b->ptr); */ | ||
209 | /* according to Tim Hudson <tjh@cryptsoft.com>, the commented | ||
210 | * out version above can cause 'inl' write calls under | ||
211 | * some stupid stdio implementations (VMS) */ | ||
212 | } | ||
213 | return (ret); | 206 | return (ret); |
214 | } | 207 | } |
215 | 208 | ||