Skip to content

Commit 0edcbac

Browse files
frasertweedalet8m
authored andcommitted
Fix documentation of BIO_FLAGS_BASE64_NO_NL
Commit 8bfb750 updated `BIO_f_base64(3)` to improve the documentation of the `BIO_FLAGS_BASE64_NO_NL` flag. In particular, the updated text states that when this flag is used, all newlines in the input are ignored. This is incorrect, as the following program proves: ```c unsigned char *in_buf = "IlRoZSBxdWljayBicm93biBmb3gganVt\ncHMgb3ZlciBhIGxhenkgZG9nLiI=\n"; int main(int argc, char **argv) { BIO *b64 = BIO_new(BIO_f_base64()); if (b64 == NULL) return 1; BIO_set_flags(b64, BIO_get_flags(b64) | BIO_FLAGS_BASE64_NO_NL); int in_len = strlen(in_buf); BIO *in = BIO_new_mem_buf(in_buf, in_len); if (in == NULL) return 2; in = BIO_push(b64, in); unsigned char *out_buf = calloc(in_len, sizeof(unsigned char)); if (out_buf == NULL) return 3; size_t out_len; int r = BIO_read_ex(in, out_buf, in_len, &out_len); printf("rv = %d\n", r); printf("decoded = %s\n", out_buf); return 0; } ``` Update the text of `BIO_f_base64(3)` to clarify that when the flag is set, the data must be all on one line (with or without a trailing newline character). Signed-off-by: Fraser Tweedale <[email protected]> Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> (Merged from openssl#18568)
1 parent 909d590 commit 0edcbac

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

doc/man3/BIO_f_base64.pod

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ to flush the final block through the BIO.
3838
The flag BIO_FLAGS_BASE64_NO_NL can be set with BIO_set_flags().
3939
For writing, it causes all data to be written on one line without
4040
newline at the end.
41-
For reading, it forces the decoder to process the data regardless
42-
of newlines. All newlines are ignored and the input does not need
43-
to contain any newline at all.
41+
For reading, it expects the data to be all on one line (with or
42+
without a trailing newline).
4443

4544
=head1 NOTES
4645

0 commit comments

Comments
 (0)