@@ -559,23 +559,28 @@ connect_pg_server(ForeignServer *server, UserMapping *user)
559
559
if (MyProcPort -> has_scram_keys && UseScramPassthrough (server , user ))
560
560
{
561
561
int len ;
562
+ int encoded_len ;
562
563
563
564
keywords [n ] = "scram_client_key" ;
564
565
len = pg_b64_enc_len (sizeof (MyProcPort -> scram_ClientKey ));
565
566
/* don't forget the zero-terminator */
566
567
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" );
570
573
n ++ ;
571
574
572
575
keywords [n ] = "scram_server_key" ;
573
576
len = pg_b64_enc_len (sizeof (MyProcPort -> scram_ServerKey ));
574
577
/* don't forget the zero-terminator */
575
578
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" );
579
584
n ++ ;
580
585
}
581
586
0 commit comments