diff options
author | Michael Paquier <michael@paquier.xyz> | 2021-07-10 21:45:28 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2021-07-10 21:45:28 +0900 |
commit | 44bd0126c70b5b90e8e2d604833a6476abbbffe6 (patch) | |
tree | 9103928081b8308011c119c6c5b92f22eb9c2dce /src/interfaces/libpq/fe-auth-sasl.h | |
parent | e7fc488ad67caaad33f6d5177081884495cb81cb (diff) |
Add more sanity checks in SASL exchanges
The following checks are added, to make the SASL infrastructure more
aware of defects when implementing new mechanisms:
- Detect that no output is generated by a mechanism if an exchange fails
in the backend, failing if there is a message waiting to be sent.
- Handle zero-length messages in the frontend. The backend handles that
already, and SCRAM would complain if sending empty messages as this is
not authorized for this mechanism, but other mechanisms may want this
capability (the SASL specification allows that).
- Make sure that a mechanism generates a message in the middle of the
exchange in the frontend.
SCRAM, as implemented, respects all these requirements already, and the
recent refactoring of SASL done in 9fd8557 helps in documenting that in
a cleaner way.
Analyzed-by: Jacob Champion
Author: Michael Paquier
Reviewed-by: Jacob Champion
Discussion: https://postgr.es/m/3d2a6f5d50e741117d6baf83eb67ebf1a8a35a11.camel@vmware.com
Diffstat (limited to 'src/interfaces/libpq/fe-auth-sasl.h')
-rw-r--r-- | src/interfaces/libpq/fe-auth-sasl.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/interfaces/libpq/fe-auth-sasl.h b/src/interfaces/libpq/fe-auth-sasl.h index 0aec588a9eb..3d7ee576f2a 100644 --- a/src/interfaces/libpq/fe-auth-sasl.h +++ b/src/interfaces/libpq/fe-auth-sasl.h @@ -78,11 +78,12 @@ typedef struct pg_fe_sasl_mech * Output parameters, to be set by the callback function: * * output: A malloc'd buffer containing the client's response to - * the server, or NULL if the exchange should be aborted. - * (*success should be set to false in the latter case.) + * the server (can be empty), or NULL if the exchange should + * be aborted. (*success should be set to false in the + * latter case.) * - * outputlen: The length of the client response buffer, or zero if no - * data should be sent due to an exchange failure + * outputlen: The length (0 or higher) of the client response buffer, + * ignored if output is NULL. * * done: Set to true if the SASL exchange should not continue, * because the exchange is either complete or failed |