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

Commite8a72c0

Browse files
committed
Prevent simple_prompt() from locking up in a tight loop at stdin EOF.
1 parent0a829cb commite8a72c0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

‎src/bin/psql/common.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.25 2000/11/13 23:37:53 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.26 2000/11/27 01:28:40 tgl Exp $
77
*/
88
#include"postgres.h"
99
#include"common.h"
@@ -217,12 +217,14 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
217217
if (length>0&&destination[length-1]!='\n')
218218
{
219219
/* eat rest of the line */
220-
charbuf[512];
220+
charbuf[128];
221+
intbuflen;
221222

222223
do
223224
{
224-
fgets(buf,512,stdin);
225-
}while (buf[strlen(buf)-1]!='\n');
225+
fgets(buf,sizeof(buf),stdin);
226+
buflen=strlen(buf);
227+
}while (buflen>0&&buf[buflen-1]!='\n');
226228
}
227229

228230
if (length>0&&destination[length-1]=='\n')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp