mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Normalize fgets() calls to use sizeof() for calculating the buffer size
where possible, and fix some sites that apparently thought that fgets() will overwrite the buffer by one byte. Also add some strlcpy() to eliminate some weird memory handling.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.341 2007/01/05 22:20:00 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.342 2007/02/08 11:10:27 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -2845,11 +2845,11 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)
|
||||
return 1;
|
||||
}
|
||||
|
||||
while ((line = fgets(buf, MAXBUFSIZE - 1, f)) != NULL)
|
||||
while ((line = fgets(buf, sizeof(buf), f)) != NULL)
|
||||
{
|
||||
linenr++;
|
||||
|
||||
if (strlen(line) >= MAXBUFSIZE - 2)
|
||||
if (strlen(line) >= sizeof(buf) - 1)
|
||||
{
|
||||
fclose(f);
|
||||
printfPQExpBuffer(errorMessage,
|
||||
@ -3654,7 +3654,7 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username)
|
||||
*ret;
|
||||
int len;
|
||||
|
||||
fgets(buf, LINELEN - 1, fp);
|
||||
fgets(buf, sizeof(buf), fp);
|
||||
|
||||
len = strlen(buf);
|
||||
if (len == 0)
|
||||
|
Reference in New Issue
Block a user