Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
5674460b
Commit
5674460b
authored
22 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Fix error recovery for SSL_read/SSL_write calls.
parent
76b45c98
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/backend/libpq/be-secure.c
+24
-18
24 additions, 18 deletions
src/backend/libpq/be-secure.c
src/interfaces/libpq/fe-secure.c
+23
-5
23 additions, 5 deletions
src/interfaces/libpq/fe-secure.c
with
47 additions
and
23 deletions
src/backend/libpq/be-secure.c
+
24
−
18
View file @
5674460b
...
...
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.2
8
2003/0
3/29 05:00:15 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.2
9
2003/0
4/10 23:03:08 tgl
Exp $
*
* Since the server static private key ($DataDir/server.key)
* will normally be stored unencrypted so that the database
...
...
@@ -276,6 +276,7 @@ secure_read(Port *port, void *ptr, size_t len)
#ifdef USE_SSL
if
(
port
->
ssl
)
{
rloop:
n
=
SSL_read
(
port
->
ssl
,
ptr
,
len
);
switch
(
SSL_get_error
(
port
->
ssl
,
n
))
{
...
...
@@ -283,14 +284,13 @@ secure_read(Port *port, void *ptr, size_t len)
port
->
count
+=
n
;
break
;
case
SSL_ERROR_WANT_READ
:
n
=
secure_read
(
port
,
ptr
,
len
);
break
;
case
SSL_ERROR_WANT_WRITE
:
n
=
secure_write
(
port
,
ptr
,
len
);
break
;
goto
rloop
;
case
SSL_ERROR_SYSCALL
:
if
(
n
==
-
1
)
elog
(
COMMERROR
,
"SSL SYSCALL error: %s"
,
strerror
(
errno
));
elog
(
COMMERROR
,
"SSL SYSCALL error: %m"
);
else
elog
(
COMMERROR
,
"SSL SYSCALL error: EOF detected"
);
break
;
case
SSL_ERROR_SSL
:
elog
(
COMMERROR
,
"SSL error: %s"
,
SSLerrmessage
());
...
...
@@ -300,6 +300,9 @@ secure_read(Port *port, void *ptr, size_t len)
errno
=
ECONNRESET
;
n
=
-
1
;
break
;
default:
elog
(
COMMERROR
,
"Unknown SSL error code"
);
break
;
}
}
else
...
...
@@ -322,18 +325,19 @@ secure_write(Port *port, void *ptr, size_t len)
{
if
(
port
->
count
>
RENEGOTIATION_LIMIT
)
{
SSL_set_session_id_context
(
port
->
ssl
,
(
void
*
)
&
SSL_context
,
sizeof
(
SSL_context
));
if
(
SSL_renegotiate
(
port
->
ssl
)
<=
0
)
elog
(
COMMERROR
,
"SSL renegotiation failure"
);
SSL_set_session_id_context
(
port
->
ssl
,
(
void
*
)
&
SSL_context
,
sizeof
(
SSL_context
));
if
(
SSL_renegotiate
(
port
->
ssl
)
<=
0
)
elog
(
COMMERROR
,
"SSL renegotiation failure"
);
if
(
SSL_do_handshake
(
port
->
ssl
)
<=
0
)
elog
(
COMMERROR
,
"SSL renegotiation failure"
);
port
->
ssl
->
state
=
SSL_ST_ACCEPT
;
elog
(
COMMERROR
,
"SSL renegotiation failure"
);
port
->
ssl
->
state
=
SSL_ST_ACCEPT
;
if
(
SSL_do_handshake
(
port
->
ssl
)
<=
0
)
elog
(
COMMERROR
,
"SSL renegotiation failure"
);
elog
(
COMMERROR
,
"SSL renegotiation failure"
);
port
->
count
=
0
;
}
wloop:
n
=
SSL_write
(
port
->
ssl
,
ptr
,
len
);
switch
(
SSL_get_error
(
port
->
ssl
,
n
))
{
...
...
@@ -341,14 +345,13 @@ secure_write(Port *port, void *ptr, size_t len)
port
->
count
+=
n
;
break
;
case
SSL_ERROR_WANT_READ
:
n
=
secure_read
(
port
,
ptr
,
len
);
break
;
case
SSL_ERROR_WANT_WRITE
:
n
=
secure_write
(
port
,
ptr
,
len
);
break
;
goto
wloop
;
case
SSL_ERROR_SYSCALL
:
if
(
n
==
-
1
)
elog
(
COMMERROR
,
"SSL SYSCALL error: %s"
,
strerror
(
errno
));
elog
(
COMMERROR
,
"SSL SYSCALL error: %m"
);
else
elog
(
COMMERROR
,
"SSL SYSCALL error: EOF detected"
);
break
;
case
SSL_ERROR_SSL
:
elog
(
COMMERROR
,
"SSL error: %s"
,
SSLerrmessage
());
...
...
@@ -358,6 +361,9 @@ secure_write(Port *port, void *ptr, size_t len)
errno
=
ECONNRESET
;
n
=
-
1
;
break
;
default:
elog
(
COMMERROR
,
"Unknown SSL error code"
);
break
;
}
}
else
...
...
This diff is collapsed.
Click to expand it.
src/interfaces/libpq/fe-secure.c
+
23
−
5
View file @
5674460b
...
...
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.2
1
2003/0
2/03 22:33:51
tgl Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.2
2
2003/0
4/10 23:03:08
tgl Exp $
*
* NOTES
* The client *requires* a valid server certificate. Since
...
...
@@ -266,19 +266,24 @@ pqsecure_read(PGconn *conn, void *ptr, size_t len)
#ifdef USE_SSL
if
(
conn
->
ssl
)
{
rloop:
n
=
SSL_read
(
conn
->
ssl
,
ptr
,
len
);
switch
(
SSL_get_error
(
conn
->
ssl
,
n
))
{
case
SSL_ERROR_NONE
:
break
;
case
SSL_ERROR_WANT_READ
:
n
=
pqsecure_read
(
conn
,
ptr
,
len
);
break
;
case
SSL_ERROR_WANT_WRITE
:
/* XXX to support nonblock I/O, we should return 0 here */
goto
rloop
;
case
SSL_ERROR_SYSCALL
:
if
(
n
==
-
1
)
printfPQExpBuffer
(
&
conn
->
errorMessage
,
libpq_gettext
(
"SSL SYSCALL error: %s
\n
"
),
SOCK_STRERROR
(
SOCK_ERRNO
));
else
printfPQExpBuffer
(
&
conn
->
errorMessage
,
libpq_gettext
(
"SSL SYSCALL error: EOF detected
\n
"
));
break
;
case
SSL_ERROR_SSL
:
printfPQExpBuffer
(
&
conn
->
errorMessage
,
...
...
@@ -289,6 +294,10 @@ pqsecure_read(PGconn *conn, void *ptr, size_t len)
SOCK_ERRNO
=
ECONNRESET
;
n
=
-
1
;
break
;
default:
printfPQExpBuffer
(
&
conn
->
errorMessage
,
libpq_gettext
(
"Unknown SSL error code
\n
"
));
break
;
}
}
else
...
...
@@ -313,19 +322,24 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
#ifdef USE_SSL
if
(
conn
->
ssl
)
{
wloop:
n
=
SSL_write
(
conn
->
ssl
,
ptr
,
len
);
switch
(
SSL_get_error
(
conn
->
ssl
,
n
))
{
case
SSL_ERROR_NONE
:
break
;
case
SSL_ERROR_WANT_READ
:
case
SSL_ERROR_WANT_WRITE
:
n
=
pqsecure_write
(
conn
,
ptr
,
len
);
break
;
/* XXX to support nonblock I/O, we should return 0 here */
goto
wloop
;
case
SSL_ERROR_SYSCALL
:
if
(
n
==
-
1
)
printfPQExpBuffer
(
&
conn
->
errorMessage
,
libpq_gettext
(
"SSL SYSCALL error: %s
\n
"
),
SOCK_STRERROR
(
SOCK_ERRNO
));
else
printfPQExpBuffer
(
&
conn
->
errorMessage
,
libpq_gettext
(
"SSL SYSCALL error: EOF detected
\n
"
));
break
;
case
SSL_ERROR_SSL
:
printfPQExpBuffer
(
&
conn
->
errorMessage
,
...
...
@@ -336,6 +350,10 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
SOCK_ERRNO
=
ECONNRESET
;
n
=
-
1
;
break
;
default:
printfPQExpBuffer
(
&
conn
->
errorMessage
,
libpq_gettext
(
"Unknown SSL error code
\n
"
));
break
;
}
}
else
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment