mirror of
https://github.com/postgres/postgres.git
synced 2026-02-12 07:13:09 -05:00
This is a follow-up refactoring after09ec55bandb674211, which has proved that the encoding and decoding routines used by SCRAM have a poor interface when it comes to check after buffer overflows. This adds an extra argument in the shape of the length of the result buffer for each routine, which is used for overflow checks when encoding or decoding an input string. The original idea comes from Tom Lane. As a result of that, the encoding routine can now fail, so all its callers are adjusted to generate proper error messages in case of problems. On failure, the result buffer gets zeroed. Author: Michael Paquier Reviewed-by: Daniel Gustafsson Discussion: https://postgr.es/m/20190623132535.GB1628@paquier.xyz
19 lines
515 B
C
19 lines
515 B
C
/*
|
|
* base64.h
|
|
* Encoding and decoding routines for base64 without whitespace
|
|
* support.
|
|
*
|
|
* Portions Copyright (c) 2001-2019, PostgreSQL Global Development Group
|
|
*
|
|
* src/include/common/base64.h
|
|
*/
|
|
#ifndef BASE64_H
|
|
#define BASE64_H
|
|
|
|
/* base 64 */
|
|
extern int pg_b64_encode(const char *src, int len, char *dst, int dstlen);
|
|
extern int pg_b64_decode(const char *src, int len, char *dst, int dstlen);
|
|
extern int pg_b64_enc_len(int srclen);
|
|
extern int pg_b64_dec_len(int srclen);
|
|
|
|
#endif /* BASE64_H */
|