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

Commit0954358

Browse files
committed
Fix a couple of places where the result of fgets() wasn't checked.
This is mostly to suppress compiler warnings, although in principlethe cases could result in undesirable behavior.Martin Pitt
1 parent21992dd commit0954358

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

‎src/bin/psql/prompt.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2010, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.53 2010/01/02 16:57:59 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.54 2010/04/30 17:09:13 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99

@@ -252,7 +252,8 @@ get_prompt(promptStatus_t status)
252252
fd=popen(file,"r");
253253
if (fd)
254254
{
255-
fgets(buf,sizeof(buf),fd);
255+
if (fgets(buf,sizeof(buf),fd)==NULL)
256+
buf[0]='\0';
256257
pclose(fd);
257258
}
258259
if (strlen(buf)>0&&buf[strlen(buf)-1]=='\n')

‎src/interfaces/libpq/fe-connect.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.391 2010/03/17 20:58:38 petere Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.392 2010/04/30 17:09:13 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -4400,7 +4400,8 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username)
44004400
*ret;
44014401
intlen;
44024402

4403-
fgets(buf,sizeof(buf),fp);
4403+
if (fgets(buf,sizeof(buf),fp)==NULL)
4404+
break;
44044405

44054406
len=strlen(buf);
44064407
if (len==0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp