Don't try to write empty early data in the tool.

We'll return 0 and get confused. (Negotiating early data and not using
it is plausible if, say, the client preconnects but gets a ServerHello
before any request binds the socket.)

Change-Id: I94d458e18c58223f73c9340cac06e5ec5f8c84a0
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/47684
Reviewed-by: Adam Langley <agl@google.com>
grpc-202302
David Benjamin 4 years ago committed by Adam Langley
parent 3675eb3f2a
commit ef1d779d7b
  1. 20
      tool/client.cc

@ -313,15 +313,17 @@ static bool DoConnection(SSL_CTX *ctx,
}
early_data = std::string(data.begin(), data.end());
}
int ed_size = early_data.size();
int ssl_ret = SSL_write(ssl.get(), early_data.data(), ed_size);
if (ssl_ret <= 0) {
int ssl_err = SSL_get_error(ssl.get(), ssl_ret);
PrintSSLError(stderr, "Error while writing", ssl_err, ssl_ret);
return false;
} else if (ssl_ret != ed_size) {
fprintf(stderr, "Short write from SSL_write.\n");
return false;
if (!early_data.empty()) {
int ed_size = early_data.size();
int ssl_ret = SSL_write(ssl.get(), early_data.data(), ed_size);
if (ssl_ret <= 0) {
int ssl_err = SSL_get_error(ssl.get(), ssl_ret);
PrintSSLError(stderr, "Error while writing", ssl_err, ssl_ret);
return false;
} else if (ssl_ret != ed_size) {
fprintf(stderr, "Short write from SSL_write.\n");
return false;
}
}
}

Loading…
Cancel
Save