1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-10 14:22:35 +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:
Tom Lane
2000-11-27 02:20:36 +00:00
parent e8a72c0db2
commit 9c5327b99b
5 changed files with 19 additions and 15 deletions

View File

@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.15 2000/11/13 23:37:53 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/prompt.c,v 1.16 2000/11/27 02:20:36 tgl Exp $
*/
#include "postgres.h"
#include "prompt.h"
@@ -277,7 +277,7 @@ get_prompt(promptStatus_t status)
fgets(buf, MAX_PROMPT_SIZE - 1, fd);
pclose(fd);
}
if (buf[strlen(buf) - 1] == '\n')
if (strlen(buf) > 0 && buf[strlen(buf) - 1] == '\n')
buf[strlen(buf) - 1] = '\0';
free(file);
p += cmdend + 1;