зеркало из https://github.com/github/ruby.git
* ext/openssl/ossl_ssl.c (ossl_ssl_read): should check for error
status by SSL_get_error(). * ext/openssl/ossl_ssl.c (ossl_ssl_write): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
6fe8d987ce
Коммит
932075e82e
|
@ -1,3 +1,10 @@
|
|||
Wed Dec 24 16:13:05 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||
|
||||
* ext/openssl/ossl_ssl.c (ossl_ssl_read): should check for error
|
||||
status by SSL_get_error().
|
||||
|
||||
* ext/openssl/ossl_ssl.c (ossl_ssl_write): ditto.
|
||||
|
||||
Wed Dec 24 14:23:27 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/stringio/stringio.c (strio_read): clear the buffer argument
|
||||
|
|
|
@ -496,11 +496,20 @@ ossl_ssl_read(VALUE self, VALUE len)
|
|||
str = rb_str_new(0, ilen);
|
||||
|
||||
if (ssl) {
|
||||
TRAP_BEG;
|
||||
nread = SSL_read(ssl, RSTRING(str)->ptr, RSTRING(str)->len);
|
||||
TRAP_END;
|
||||
if (nread < 0) {
|
||||
ossl_raise(eSSLError, "SSL_read:");
|
||||
for (;;){
|
||||
nread = SSL_read(ssl, RSTRING(str)->ptr, RSTRING(str)->len);
|
||||
switch(SSL_get_error(ssl, nread)){
|
||||
case SSL_ERROR_NONE:
|
||||
goto end;
|
||||
case SSL_ERROR_ZERO_RETURN:
|
||||
ossl_raise(rb_eEOFError, "End of file reached");
|
||||
case SSL_ERROR_WANT_WRITE:
|
||||
case SSL_ERROR_WANT_READ:
|
||||
rb_thread_schedule();
|
||||
continue;
|
||||
default:
|
||||
ossl_raise(eSSLError, "SSL_read:");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -510,15 +519,15 @@ ossl_ssl_read(VALUE self, VALUE len)
|
|||
TRAP_BEG;
|
||||
nread = read(fileno(fptr->f), RSTRING(str)->ptr, RSTRING(str)->len);
|
||||
TRAP_END;
|
||||
if (nread == 0) {
|
||||
ossl_raise(rb_eEOFError, "End of file reached");
|
||||
}
|
||||
if(nread < 0) {
|
||||
ossl_raise(eSSLError, "read:%s", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
if (nread == 0) {
|
||||
ossl_raise(rb_eEOFError, "End of file reached");
|
||||
}
|
||||
|
||||
end:
|
||||
RSTRING(str)->len = nread;
|
||||
RSTRING(str)->ptr[nread] = 0;
|
||||
OBJ_TAINT(str);
|
||||
|
@ -538,9 +547,18 @@ ossl_ssl_write(VALUE self, VALUE str)
|
|||
StringValue(str);
|
||||
|
||||
if (ssl) {
|
||||
nwrite = SSL_write(ssl, RSTRING(str)->ptr, RSTRING(str)->len);
|
||||
if (nwrite <= 0) {
|
||||
ossl_raise(eSSLError, "SSL_write:");
|
||||
for (;;){
|
||||
nwrite = SSL_write(ssl, RSTRING(str)->ptr, RSTRING(str)->len);
|
||||
switch(SSL_get_error(ssl, nwrite)){
|
||||
case SSL_ERROR_NONE:
|
||||
goto end;
|
||||
case SSL_ERROR_WANT_WRITE:
|
||||
case SSL_ERROR_WANT_READ:
|
||||
rb_thread_schedule();
|
||||
continue;
|
||||
default:
|
||||
ossl_raise(eSSLError, "SSL_write:");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -554,6 +572,7 @@ ossl_ssl_write(VALUE self, VALUE str)
|
|||
}
|
||||
}
|
||||
|
||||
end:
|
||||
return INT2NUM(nwrite);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче