提交 2f8e53d7 编写于 作者: F FdaSilvaYY 提交者: Rich Salz

Fix if/for/while( in docs

Reviewed-by: NMatt Caswell <matt@openssl.org>
Reviewed-by: NRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1292)
上级 e8aa8b6c
...@@ -107,7 +107,7 @@ The next example digests data by reading through a chain instead: ...@@ -107,7 +107,7 @@ The next example digests data by reading through a chain instead:
do { do {
rdlen = BIO_read(bio, buf, sizeof(buf)); rdlen = BIO_read(bio, buf, sizeof(buf));
/* Might want to do something with the data here */ /* Might want to do something with the data here */
} while(rdlen > 0); } while (rdlen > 0);
This next example retrieves the message digests from a BIO chain and This next example retrieves the message digests from a BIO chain and
outputs them. This could be used with the examples above. outputs them. This could be used with the examples above.
...@@ -120,14 +120,14 @@ outputs them. This could be used with the examples above. ...@@ -120,14 +120,14 @@ outputs them. This could be used with the examples above.
do { do {
EVP_MD *md; EVP_MD *md;
mdtmp = BIO_find_type(mdtmp, BIO_TYPE_MD); mdtmp = BIO_find_type(mdtmp, BIO_TYPE_MD);
if(!mdtmp) break; if (!mdtmp) break;
BIO_get_md(mdtmp, &md); BIO_get_md(mdtmp, &md);
printf("%s digest", OBJ_nid2sn(EVP_MD_type(md))); printf("%s digest", OBJ_nid2sn(EVP_MD_type(md)));
mdlen = BIO_gets(mdtmp, mdbuf, EVP_MAX_MD_SIZE); mdlen = BIO_gets(mdtmp, mdbuf, EVP_MAX_MD_SIZE);
for(i = 0; i < mdlen; i++) printf(":%02X", mdbuf[i]); for (i = 0; i < mdlen; i++) printf(":%02X", mdbuf[i]);
printf("\n"); printf("\n");
mdtmp = BIO_next(mdtmp); mdtmp = BIO_next(mdtmp);
} while(mdtmp); } while (mdtmp);
BIO_free_all(bio); BIO_free_all(bio);
......
...@@ -180,7 +180,7 @@ unencrypted example in L<BIO_s_connect(3)>. ...@@ -180,7 +180,7 @@ unencrypted example in L<BIO_s_connect(3)>.
BIO_puts(sbio, "GET / HTTP/1.0\n\n"); BIO_puts(sbio, "GET / HTTP/1.0\n\n");
for ( ; ; ) { for ( ; ; ) {
len = BIO_read(sbio, tmpbuf, 1024); len = BIO_read(sbio, tmpbuf, 1024);
if(len <= 0) if (len <= 0)
break; break;
BIO_write(out, tmpbuf, len); BIO_write(out, tmpbuf, len);
} }
......
...@@ -49,12 +49,12 @@ Traverse a chain looking for digest BIOs: ...@@ -49,12 +49,12 @@ Traverse a chain looking for digest BIOs:
do { do {
btmp = BIO_find_type(btmp, BIO_TYPE_MD); btmp = BIO_find_type(btmp, BIO_TYPE_MD);
if(btmp == NULL) break; /* Not found */ if (btmp == NULL) break; /* Not found */
/* btmp is a digest BIO, do something with it ...*/ /* btmp is a digest BIO, do something with it ...*/
... ...
btmp = BIO_next(btmp); btmp = BIO_next(btmp);
} while(btmp); } while (btmp);
=head1 COPYRIGHT =head1 COPYRIGHT
......
...@@ -176,7 +176,7 @@ to retrieve a page and copy the result to standard output. ...@@ -176,7 +176,7 @@ to retrieve a page and copy the result to standard output.
BIO_puts(cbio, "GET / HTTP/1.0\n\n"); BIO_puts(cbio, "GET / HTTP/1.0\n\n");
for ( ; ; ) { for ( ; ; ) {
len = BIO_read(cbio, tmpbuf, 1024); len = BIO_read(cbio, tmpbuf, 1024);
if(len <= 0) if (len <= 0)
break; break;
BIO_write(out, tmpbuf, len); BIO_write(out, tmpbuf, len);
} }
......
...@@ -92,15 +92,15 @@ Alternative technique: ...@@ -92,15 +92,15 @@ Alternative technique:
BIO *bio_out; BIO *bio_out;
bio_out = BIO_new(BIO_s_file()); bio_out = BIO_new(BIO_s_file());
if(bio_out == NULL) /* Error ... */ if (bio_out == NULL) /* Error ... */
if(!BIO_set_fp(bio_out, stdout, BIO_NOCLOSE)) /* Error ... */ if (!BIO_set_fp(bio_out, stdout, BIO_NOCLOSE)) /* Error ... */
BIO_printf(bio_out, "Hello World\n"); BIO_printf(bio_out, "Hello World\n");
Write to a file: Write to a file:
BIO *out; BIO *out;
out = BIO_new_file("filename.txt", "w"); out = BIO_new_file("filename.txt", "w");
if(!out) /* Error occurred */ if (!out) /* Error occurred */
BIO_printf(out, "Hello World\n"); BIO_printf(out, "Hello World\n");
BIO_free(out); BIO_free(out);
...@@ -108,8 +108,8 @@ Alternative technique: ...@@ -108,8 +108,8 @@ Alternative technique:
BIO *out; BIO *out;
out = BIO_new(BIO_s_file()); out = BIO_new(BIO_s_file());
if(out == NULL) /* Error ... */ if (out == NULL) /* Error ... */
if(!BIO_write_filename(out, "filename.txt")) /* Error ... */ if (!BIO_write_filename(out, "filename.txt")) /* Error ... */
BIO_printf(out, "Hello World\n"); BIO_printf(out, "Hello World\n");
BIO_free(out); BIO_free(out);
......
...@@ -472,8 +472,8 @@ boolean success or failure. ...@@ -472,8 +472,8 @@ boolean success or failure.
const char **post_cmds, int post_num) const char **post_cmds, int post_num)
{ {
ENGINE *e = ENGINE_by_id(engine_id); ENGINE *e = ENGINE_by_id(engine_id);
if(!e) return 0; if (!e) return 0;
while(pre_num--) { while (pre_num--) {
if(!ENGINE_ctrl_cmd_string(e, pre_cmds[0], pre_cmds[1], 0)) { if(!ENGINE_ctrl_cmd_string(e, pre_cmds[0], pre_cmds[1], 0)) {
fprintf(stderr, "Failed command (%s - %s:%s)\n", engine_id, fprintf(stderr, "Failed command (%s - %s:%s)\n", engine_id,
pre_cmds[0], pre_cmds[1] ? pre_cmds[1] : "(NULL)"); pre_cmds[0], pre_cmds[1] ? pre_cmds[1] : "(NULL)");
...@@ -482,7 +482,7 @@ boolean success or failure. ...@@ -482,7 +482,7 @@ boolean success or failure.
} }
pre_cmds += 2; pre_cmds += 2;
} }
if(!ENGINE_init(e)) { if (!ENGINE_init(e)) {
fprintf(stderr, "Failed initialisation\n"); fprintf(stderr, "Failed initialisation\n");
ENGINE_free(e); ENGINE_free(e);
return 0; return 0;
......
...@@ -223,7 +223,7 @@ digest name passed on the command line. ...@@ -223,7 +223,7 @@ digest name passed on the command line.
EVP_MD_CTX_free(mdctx); EVP_MD_CTX_free(mdctx);
printf("Digest is: "); printf("Digest is: ");
for(i = 0; i < md_len; i++) for (i = 0; i < md_len; i++)
printf("%02x", md_value[i]); printf("%02x", md_value[i]);
printf("\n"); printf("\n");
......
...@@ -603,7 +603,7 @@ with a 128-bit key: ...@@ -603,7 +603,7 @@ with a 128-bit key:
for(;;) for(;;)
{ {
inlen = fread(inbuf, 1, 1024, in); inlen = fread(inbuf, 1, 1024, in);
if(inlen <= 0) break; if (inlen <= 0) break;
if(!EVP_CipherUpdate(ctx, outbuf, &outlen, inbuf, inlen)) if(!EVP_CipherUpdate(ctx, outbuf, &outlen, inbuf, inlen))
{ {
/* Error */ /* Error */
......
...@@ -90,25 +90,27 @@ server id given, and will fill the rest with pseudo random bytes: ...@@ -90,25 +90,27 @@ server id given, and will fill the rest with pseudo random bytes:
#define MAX_SESSION_ID_ATTEMPTS 10 #define MAX_SESSION_ID_ATTEMPTS 10
static int generate_session_id(const SSL *ssl, unsigned char *id, static int generate_session_id(const SSL *ssl, unsigned char *id,
unsigned int *id_len) unsigned int *id_len)
{ {
unsigned int count = 0; unsigned int count = 0;
do { do {
RAND_pseudo_bytes(id, *id_len); RAND_pseudo_bytes(id, *id_len);
/* Prefix the session_id with the required prefix. NB: If our /*
* prefix is too long, clip it - but there will be worse effects * Prefix the session_id with the required prefix. NB: If our
* anyway, eg. the server could only possibly create 1 session * prefix is too long, clip it - but there will be worse effects
* ID (ie. the prefix!) so all future session negotiations will * anyway, eg. the server could only possibly create 1 session
* fail due to conflicts. */ * ID (ie. the prefix!) so all future session negotiations will
memcpy(id, session_id_prefix, * fail due to conflicts.
(strlen(session_id_prefix) < *id_len) ? */
strlen(session_id_prefix) : *id_len); memcpy(id, session_id_prefix,
} (strlen(session_id_prefix) < *id_len) ?
while(SSL_has_matching_session_id(ssl, id, *id_len) && strlen(session_id_prefix) : *id_len);
}
while (SSL_has_matching_session_id(ssl, id, *id_len) &&
(++count < MAX_SESSION_ID_ATTEMPTS)); (++count < MAX_SESSION_ID_ATTEMPTS));
if(count >= MAX_SESSION_ID_ATTEMPTS) if (count >= MAX_SESSION_ID_ATTEMPTS)
return 0; return 0;
return 1; return 1;
} }
=head1 RETURN VALUES =head1 RETURN VALUES
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册