Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6afe200

Browse files
committed
chkpass: check for NULL return value from crypt()
Report from Jozef Mlich using Coverity
1 parent85317e8 commit6afe200

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

‎contrib/chkpass/chkpass.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ chkpass_in(PG_FUNCTION_ARGS)
7070
char*str=PG_GETARG_CSTRING(0);
7171
chkpass*result;
7272
charmysalt[4];
73+
char*crypt_output;
7374
staticcharsalt_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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp