@@ -559,23 +559,28 @@ connect_pg_server(ForeignServer *server, UserMapping *user)
559559 if (MyProcPort -> has_scram_keys && UseScramPassthrough (server , user ))
560560 {
561561 int len ;
562+ int encoded_len ;
562563
563564 keywords [n ] = "scram_client_key" ;
564565 len = pg_b64_enc_len (sizeof (MyProcPort -> scram_ClientKey ));
565566 /* don't forget the zero-terminator */
566567 values [n ] = palloc0 (len + 1 );
567- pg_b64_encode ((const char * ) MyProcPort -> scram_ClientKey ,
568- sizeof (MyProcPort -> scram_ClientKey ),
569- (char * ) values [n ], len );
568+ encoded_len = pg_b64_encode ((const char * ) MyProcPort -> scram_ClientKey ,
569+ sizeof (MyProcPort -> scram_ClientKey ),
570+ (char * ) values [n ], len );
571+ if (encoded_len < 0 )
572+ elog (ERROR , "could not encode SCRAM client key" );
570573 n ++ ;
571574
572575 keywords [n ] = "scram_server_key" ;
573576 len = pg_b64_enc_len (sizeof (MyProcPort -> scram_ServerKey ));
574577 /* don't forget the zero-terminator */
575578 values [n ] = palloc0 (len + 1 );
576- pg_b64_encode ((const char * ) MyProcPort -> scram_ServerKey ,
577- sizeof (MyProcPort -> scram_ServerKey ),
578- (char * ) values [n ], len );
579+ encoded_len = pg_b64_encode ((const char * ) MyProcPort -> scram_ServerKey ,
580+ sizeof (MyProcPort -> scram_ServerKey ),
581+ (char * ) values [n ], len );
582+ if (encoded_len < 0 )
583+ elog (ERROR , "could not encode SCRAM server key" );
579584 n ++ ;
580585 }
581586
0 commit comments