Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
9c5327b9
Commit
9c5327b9
authored
Nov 27, 2000
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pay attention to failure returns from fgets() in all cases.
Avoid infinite loop prompting for password at stdin EOF.
parent
e8a72c0d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
15 deletions
+19
-15
src/bin/psql/command.c
src/bin/psql/command.c
+4
-3
src/bin/psql/common.c
src/bin/psql/common.c
+8
-6
src/bin/psql/input.c
src/bin/psql/input.c
+2
-2
src/bin/psql/prompt.c
src/bin/psql/prompt.c
+2
-2
src/bin/psql/startup.c
src/bin/psql/startup.c
+3
-2
No files found.
src/bin/psql/command.c
View file @
9c5327b9
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright 2000 by PostgreSQL Global Development Group
* Copyright 2000 by PostgreSQL Global Development Group
*
*
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.4
0 2000/11/26 11:09:32 petere
Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.4
1 2000/11/27 02:20:36 tgl
Exp $
*/
*/
#include "postgres.h"
#include "postgres.h"
#include "command.h"
#include "command.h"
...
@@ -1236,7 +1236,8 @@ do_connect(const char *new_dbname, const char *new_user)
...
@@ -1236,7 +1236,8 @@ do_connect(const char *new_dbname, const char *new_user)
NULL
,
NULL
,
dbparam
,
userparam
,
pwparam
);
NULL
,
NULL
,
dbparam
,
userparam
,
pwparam
);
if
(
PQstatus
(
pset
.
db
)
==
CONNECTION_BAD
&&
if
(
PQstatus
(
pset
.
db
)
==
CONNECTION_BAD
&&
strcmp
(
PQerrorMessage
(
pset
.
db
),
"fe_sendauth: no password supplied
\n
"
)
==
0
)
strcmp
(
PQerrorMessage
(
pset
.
db
),
"fe_sendauth: no password supplied
\n
"
)
==
0
&&
!
feof
(
stdin
))
{
{
PQfinish
(
pset
.
db
);
PQfinish
(
pset
.
db
);
need_pass
=
true
;
need_pass
=
true
;
...
@@ -1491,7 +1492,7 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
...
@@ -1491,7 +1492,7 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
char
line
[
1024
];
char
line
[
1024
];
resetPQExpBuffer
(
query_buf
);
resetPQExpBuffer
(
query_buf
);
while
(
fgets
(
line
,
1024
,
stream
)
)
while
(
fgets
(
line
,
sizeof
(
line
),
stream
)
!=
NULL
)
appendPQExpBufferStr
(
query_buf
,
line
);
appendPQExpBufferStr
(
query_buf
,
line
);
if
(
ferror
(
stream
))
if
(
ferror
(
stream
))
...
...
src/bin/psql/common.c
View file @
9c5327b9
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright 2000 by PostgreSQL Global Development Group
* Copyright 2000 by PostgreSQL Global Development Group
*
*
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.2
6 2000/11/27 01:28:40
tgl Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.2
7 2000/11/27 02:20:36
tgl Exp $
*/
*/
#include "postgres.h"
#include "postgres.h"
#include "common.h"
#include "common.h"
...
@@ -201,7 +201,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
...
@@ -201,7 +201,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
}
}
#endif
#endif
fgets
(
destination
,
maxlen
,
stdin
);
if
(
fgets
(
destination
,
maxlen
,
stdin
)
==
NULL
)
destination
[
0
]
=
'\0'
;
#ifdef HAVE_TERMIOS_H
#ifdef HAVE_TERMIOS_H
if
(
!
echo
)
if
(
!
echo
)
...
@@ -222,7 +223,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
...
@@ -222,7 +223,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
do
do
{
{
fgets
(
buf
,
sizeof
(
buf
),
stdin
);
if
(
fgets
(
buf
,
sizeof
(
buf
),
stdin
)
==
NULL
)
break
;
buflen
=
strlen
(
buf
);
buflen
=
strlen
(
buf
);
}
while
(
buflen
>
0
&&
buf
[
buflen
-
1
]
!=
'\n'
);
}
while
(
buflen
>
0
&&
buf
[
buflen
-
1
]
!=
'\n'
);
}
}
...
@@ -389,9 +391,9 @@ SendQuery(const char *query)
...
@@ -389,9 +391,9 @@ SendQuery(const char *query)
"***(press return to proceed or enter x and return to cancel)********************
\n
"
,
"***(press return to proceed or enter x and return to cancel)********************
\n
"
,
query
);
query
);
fflush
(
stdout
);
fflush
(
stdout
);
fgets
(
buf
,
3
,
stdin
);
if
(
fgets
(
buf
,
sizeof
(
buf
),
stdin
)
!=
NULL
)
if
(
buf
[
0
]
==
'x'
)
if
(
buf
[
0
]
==
'x'
)
return
false
;
return
false
;
}
}
else
else
{
{
...
...
src/bin/psql/input.c
View file @
9c5327b9
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright 2000 by PostgreSQL Global Development Group
* Copyright 2000 by PostgreSQL Global Development Group
*
*
* $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.1
3 2000/04/12 17:16:22 momjian
Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.1
4 2000/11/27 02:20:36 tgl
Exp $
*/
*/
#include "postgres.h"
#include "postgres.h"
#include "input.h"
#include "input.h"
...
@@ -91,7 +91,7 @@ gets_fromFile(FILE *source)
...
@@ -91,7 +91,7 @@ gets_fromFile(FILE *source)
initPQExpBuffer
(
&
buffer
);
initPQExpBuffer
(
&
buffer
);
while
(
fgets
(
line
,
1024
,
source
)
!=
NULL
)
while
(
fgets
(
line
,
sizeof
(
line
)
,
source
)
!=
NULL
)
{
{
appendPQExpBufferStr
(
&
buffer
,
line
);
appendPQExpBufferStr
(
&
buffer
,
line
);
if
(
buffer
.
data
[
buffer
.
len
-
1
]
==
'\n'
)
if
(
buffer
.
data
[
buffer
.
len
-
1
]
==
'\n'
)
...
...
src/bin/psql/prompt.c
View file @
9c5327b9
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright 2000 by PostgreSQL Global Development Group
* Copyright 2000 by PostgreSQL Global Development Group
*
*
* $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.1
5 2000/11/13 23:37:53 momjian
Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.1
6 2000/11/27 02:20:36 tgl
Exp $
*/
*/
#include "postgres.h"
#include "postgres.h"
#include "prompt.h"
#include "prompt.h"
...
@@ -277,7 +277,7 @@ get_prompt(promptStatus_t status)
...
@@ -277,7 +277,7 @@ get_prompt(promptStatus_t status)
fgets
(
buf
,
MAX_PROMPT_SIZE
-
1
,
fd
);
fgets
(
buf
,
MAX_PROMPT_SIZE
-
1
,
fd
);
pclose
(
fd
);
pclose
(
fd
);
}
}
if
(
buf
[
strlen
(
buf
)
-
1
]
==
'\n'
)
if
(
strlen
(
buf
)
>
0
&&
buf
[
strlen
(
buf
)
-
1
]
==
'\n'
)
buf
[
strlen
(
buf
)
-
1
]
=
'\0'
;
buf
[
strlen
(
buf
)
-
1
]
=
'\0'
;
free
(
file
);
free
(
file
);
p
+=
cmdend
+
1
;
p
+=
cmdend
+
1
;
...
...
src/bin/psql/startup.c
View file @
9c5327b9
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright 2000 by PostgreSQL Global Development Group
* Copyright 2000 by PostgreSQL Global Development Group
*
*
* $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.4
0 2000/11/25 19:05:44 petere
Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.4
1 2000/11/27 02:20:36 tgl
Exp $
*/
*/
#include "postgres.h"
#include "postgres.h"
...
@@ -180,7 +180,8 @@ main(int argc, char *argv[])
...
@@ -180,7 +180,8 @@ main(int argc, char *argv[])
username
,
password
);
username
,
password
);
if
(
PQstatus
(
pset
.
db
)
==
CONNECTION_BAD
&&
if
(
PQstatus
(
pset
.
db
)
==
CONNECTION_BAD
&&
strcmp
(
PQerrorMessage
(
pset
.
db
),
"fe_sendauth: no password supplied
\n
"
)
==
0
)
strcmp
(
PQerrorMessage
(
pset
.
db
),
"fe_sendauth: no password supplied
\n
"
)
==
0
&&
!
feof
(
stdin
))
{
{
PQfinish
(
pset
.
db
);
PQfinish
(
pset
.
db
);
need_pass
=
true
;
need_pass
=
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment