mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Pay attention to failure returns from fgets() in all cases.
Avoid infinite loop prompting for password at stdin EOF.
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright 2000 by PostgreSQL Global Development Group
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.40 2000/11/26 11:09:32 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.41 2000/11/27 02:20:36 tgl Exp $
|
||||
*/
|
||||
#include "postgres.h"
|
||||
#include "command.h"
|
||||
@ -1236,7 +1236,8 @@ do_connect(const char *new_dbname, const char *new_user)
|
||||
NULL, NULL, dbparam, userparam, pwparam);
|
||||
|
||||
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);
|
||||
need_pass = true;
|
||||
@ -1491,7 +1492,7 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
|
||||
char line[1024];
|
||||
|
||||
resetPQExpBuffer(query_buf);
|
||||
while (fgets(line, 1024, stream))
|
||||
while (fgets(line, sizeof(line), stream) != NULL)
|
||||
appendPQExpBufferStr(query_buf, line);
|
||||
|
||||
if (ferror(stream))
|
||||
|
Reference in New Issue
Block a user