File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ chkpass_in(PG_FUNCTION_ARGS)
7070 char * str = PG_GETARG_CSTRING (0 );
7171 chkpass * result ;
7272 char mysalt [4 ];
73+ char * crypt_output ;
7374 static char salt_chars [] =
7475 "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ;
7576
@@ -92,7 +93,13 @@ chkpass_in(PG_FUNCTION_ARGS)
9293 mysalt [1 ] = salt_chars [random () & 0x3f ];
9394 mysalt [2 ] = 0 ; /* technically the terminator is not necessary
9495 * but I like to play safe */
95- strcpy (result -> password , crypt (str , mysalt ));
96+
97+ if ((crypt_output = crypt (str , mysalt )) == NULL )
98+ ereport (ERROR ,
99+ (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
100+ errmsg ("crypt() failed" )));
101+ strcpy (result -> password , crypt_output );
102+
96103 PG_RETURN_POINTER (result );
97104}
98105
You can’t perform that action at this time.
0 commit comments