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

Commit8d15e3e

Browse files
committed
Don't forget to de-escape the password field in .pgpass.
This has been broken just about forever (or more specifically, commit7f4981f) and nobody noticed untilRichard Huxton reported it recently. Analysis and fix by RossReedstrom, although I didn't use his patch. This doesn't seemimportant enough to back-patch and is mildly backward incompatible, soI'm just doing this in master.
1 parentc31224e commit8d15e3e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

‎src/interfaces/libpq/fe-connect.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4904,7 +4904,9 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username)
49044904
while (!feof(fp)&& !ferror(fp))
49054905
{
49064906
char*t=buf,
4907-
*ret;
4907+
*ret,
4908+
*p1,
4909+
*p2;
49084910
intlen;
49094911

49104912
if (fgets(buf,sizeof(buf),fp)==NULL)
@@ -4925,6 +4927,16 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username)
49254927
continue;
49264928
ret=strdup(t);
49274929
fclose(fp);
4930+
4931+
/* De-escape password. */
4932+
for (p1=p2=ret;*p1!=':'&&*p1!='\0';++p1,++p2)
4933+
{
4934+
if (*p1=='\\'&&p1[1]!='\0')
4935+
++p1;
4936+
*p2=*p1;
4937+
}
4938+
*p2='\0';
4939+
49284940
returnret;
49294941
}
49304942

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp