forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb55b4da
committed
Teach libpq to handle arbitrary-length lines in .pgpass files.
Historically there's been a hard-wired assumption here that no line ofa .pgpass file could be as long as NAMEDATALEN*5 bytes. That's a bitshaky to start off with, because (a) there's no reason to suppose thathost names fit in NAMEDATALEN, and (b) this figure fails to allow forbackslash escape characters. However, it fails completely if someonewants to use a very long password, and we're now hearing reports ofpeople wanting to use "security tokens" that can run up to severalhundred bytes. Another angle is that the file is specified to allowcomment lines, but there's no reason to assume that long comment linesaren't possible.Rather than guessing at what might be a more suitable limit, let'sreplace the fixed-size buffer with an expansible PQExpBuffer. Thatadds one malloc/free cycle to the typical use-case, but that's surelypretty cheap relative to the I/O this code has to do.Also, add TAP test cases to exercise this code, because there was notest coverage before.This reverts most of commit2eb3bc5, as there's no longer a need fora warning message about overlength .pgpass lines. (I kept the explicitcheck for comment lines, though.)In HEAD and v13, this also fixes an oversight in74a308c: there's notmuch point in explicit_bzero'ing the line buffer if we only do so in twoof the three exit paths.Back-patch to all supported branches, except that the test case onlygoes back to v10 where src/test/authentication/ was added.Discussion:https://postgr.es/m/4187382.1598909041@sss.pgh.pa.us1 parent4ab7769 commitb55b4da
File tree
2 files changed
+79
-69
lines changed- src
- interfaces/libpq
- test/authentication/t
2 files changed
+79
-69
lines changedLines changed: 52 additions & 67 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6937 | 6937 |
| |
6938 | 6938 |
| |
6939 | 6939 |
| |
6940 |
| - | |
6941 |
| - | |
6942 |
| - | |
6943 |
| - | |
| 6940 | + | |
6944 | 6941 |
| |
6945 | 6942 |
| |
6946 | 6943 |
| |
| |||
6996 | 6993 |
| |
6997 | 6994 |
| |
6998 | 6995 |
| |
| 6996 | + | |
| 6997 | + | |
| 6998 | + | |
6999 | 6999 |
| |
7000 | 7000 |
| |
7001 |
| - | |
7002 |
| - | |
7003 |
| - | |
7004 |
| - | |
7005 |
| - | |
7006 |
| - | |
| 7001 | + | |
| 7002 | + | |
| 7003 | + | |
7007 | 7004 |
| |
7008 |
| - | |
| 7005 | + | |
| 7006 | + | |
7009 | 7007 |
| |
| 7008 | + | |
7010 | 7009 |
| |
7011 |
| - | |
7012 |
| - | |
7013 |
| - | |
| 7010 | + | |
| 7011 | + | |
| 7012 | + | |
| 7013 | + | |
| 7014 | + | |
| 7015 | + | |
7014 | 7016 |
| |
7015 |
| - | |
7016 |
| - | |
| 7017 | + | |
| 7018 | + | |
7017 | 7019 |
| |
7018 |
| - | |
7019 |
| - | |
7020 |
| - | |
7021 |
| - | |
7022 |
| - | |
7023 |
| - | |
7024 |
| - | |
7025 |
| - | |
| 7020 | + | |
| 7021 | + | |
7026 | 7022 |
| |
7027 |
| - | |
7028 |
| - | |
| 7023 | + | |
| 7024 | + | |
| 7025 | + | |
| 7026 | + | |
| 7027 | + | |
7029 | 7028 |
| |
7030 |
| - | |
7031 |
| - | |
7032 |
| - | |
7033 |
| - | |
7034 |
| - | |
7035 |
| - | |
7036 |
| - | |
7037 |
| - | |
7038 |
| - | |
7039 |
| - | |
7040 |
| - | |
7041 |
| - | |
7042 |
| - | |
7043 |
| - | |
| 7029 | + | |
| 7030 | + | |
| 7031 | + | |
| 7032 | + | |
7044 | 7033 |
| |
7045 |
| - | |
7046 |
| - | |
| 7034 | + | |
7047 | 7035 |
| |
7048 |
| - | |
7049 |
| - | |
7050 |
| - | |
7051 |
| - | |
7052 |
| - | |
| 7036 | + | |
| 7037 | + | |
| 7038 | + | |
7053 | 7039 |
| |
7054 |
| - | |
7055 |
| - | |
7056 |
| - | |
| 7040 | + | |
| 7041 | + | |
| 7042 | + | |
| 7043 | + | |
| 7044 | + | |
7057 | 7045 |
| |
7058 |
| - | |
7059 |
| - | |
7060 |
| - | |
7061 |
| - | |
7062 |
| - | |
7063 |
| - | |
| 7046 | + | |
| 7047 | + | |
| 7048 | + | |
| 7049 | + | |
| 7050 | + | |
| 7051 | + | |
| 7052 | + | |
| 7053 | + | |
7064 | 7054 |
| |
7065 |
| - | |
7066 |
| - | |
7067 |
| - | |
7068 |
| - | |
7069 |
| - | |
7070 |
| - | |
| 7055 | + | |
| 7056 | + | |
7071 | 7057 |
| |
7072 |
| - | |
7073 | 7058 |
| |
7074 |
| - | |
| 7059 | + | |
| 7060 | + | |
7075 | 7061 |
| |
7076 | 7062 |
| |
7077 | 7063 |
| |
7078 |
| - | |
| 7064 | + | |
| 7065 | + | |
7079 | 7066 |
| |
7080 |
| - | |
7081 |
| - | |
7082 | 7067 |
| |
7083 | 7068 |
| |
7084 | 7069 |
| |
|
Lines changed: 27 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
17 | 17 |
| |
18 | 18 |
| |
19 | 19 |
| |
20 |
| - | |
| 20 | + | |
21 | 21 |
| |
22 | 22 |
| |
23 | 23 |
| |
| |||
45 | 45 |
| |
46 | 46 |
| |
47 | 47 |
| |
48 |
| - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
49 | 51 |
| |
50 | 52 |
| |
51 | 53 |
| |
| |||
96 | 98 |
| |
97 | 99 |
| |
98 | 100 |
| |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + |
0 commit comments
Comments
(0)