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

Commit80986e8

Browse files
committed
Avoid returning undefined bytes in chkpass_in().
We can't really fix the problem that the result is defined to depend onrandom(), so it is still going to fail the "unstable input conversion"test in parse_type.c. However, we can at least satify valgrind. (Itlooks like this code used to be valgrind-clean, actually, until somebodydid a careless s/strncpy/strlcpy/g on it.)In passing, let's just make real sure that chkpass_out doesn't overrunits output buffer.No need for backpatch, I think, since this is just to satisfy debuggingtools.Asif Naeem
1 parent33e879c commit80986e8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎contrib/chkpass/chkpass.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ chkpass_in(PG_FUNCTION_ARGS)
6565
/* special case to let us enter encrypted passwords */
6666
if (*str==':')
6767
{
68-
result= (chkpass*)palloc(sizeof(chkpass));
68+
result= (chkpass*)palloc0(sizeof(chkpass));
6969
strlcpy(result->password,str+1,13+1);
7070
PG_RETURN_POINTER(result);
7171
}
@@ -75,7 +75,7 @@ chkpass_in(PG_FUNCTION_ARGS)
7575
(errcode(ERRCODE_DATA_EXCEPTION),
7676
errmsg("password \"%s\" is weak",str)));
7777

78-
result= (chkpass*)palloc(sizeof(chkpass));
78+
result= (chkpass*)palloc0(sizeof(chkpass));
7979

8080
mysalt[0]=salt_chars[random()&0x3f];
8181
mysalt[1]=salt_chars[random()&0x3f];
@@ -107,7 +107,7 @@ chkpass_out(PG_FUNCTION_ARGS)
107107

108108
result= (char*)palloc(16);
109109
result[0]=':';
110-
strcpy(result+1,password->password);
110+
strlcpy(result+1,password->password,15);
111111

112112
PG_RETURN_CSTRING(result);
113113
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp