We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parent85317e8 commit6afe200Copy full SHA for 6afe200
contrib/chkpass/chkpass.c
@@ -70,6 +70,7 @@ chkpass_in(PG_FUNCTION_ARGS)
70
char*str=PG_GETARG_CSTRING(0);
71
chkpass*result;
72
charmysalt[4];
73
+char*crypt_output;
74
staticcharsalt_chars[]=
75
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
76
@@ -92,7 +93,13 @@ chkpass_in(PG_FUNCTION_ARGS)
92
93
mysalt[1]=salt_chars[random()&0x3f];
94
mysalt[2]=0;/* technically the terminator is not necessary
95
* but I like to play safe */
-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
103
PG_RETURN_POINTER(result);
104
}
105