Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1ad6878

Browse files
committed
Revert patch that removed BUFSIZ usage. The memory has to hold the
structures plus pointers used by the structure.
1 parent dd67707 commit 1ad6878

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

src/interfaces/libpq/fe-auth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.92 2004/09/27 23:38:45 momjian Exp $
13+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.93 2004/09/28 00:06:02 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -749,7 +749,7 @@ fe_getauthname(char *PQerrormsg)
749749
if (GetUserName(username, &namesize))
750750
name = username;
751751
#else
752-
char pwdbuf[sizeof(struct passwd)];
752+
char pwdbuf[BUFSIZ];
753753
struct passwd pwdstr;
754754
struct passwd *pw = NULL;
755755

src/interfaces/libpq/fe-secure.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.53 2004/09/27 23:38:45 momjian Exp $
14+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.54 2004/09/28 00:06:02 momjian Exp $
1515
*
1616
* NOTES
1717
* [ Most of these notes are wrong/obsolete, but perhaps not all ]
@@ -512,7 +512,7 @@ verify_peer(PGconn *conn)
512512

513513
{
514514
struct hostent hpstr;
515-
char buf[sizeof(struct hostent)];
515+
char buf[BUFSIZ];
516516
int herrno = 0;
517517

518518
/*
@@ -598,7 +598,7 @@ load_dh_file(int keylength)
598598
#ifdef WIN32
599599
return NULL;
600600
#else
601-
char pwdbuf[sizeof(struct passwd)];
601+
char pwdbuf[BUFSIZ];
602602
struct passwd pwdstr;
603603
struct passwd *pwd = NULL;
604604
FILE *fp;
@@ -745,7 +745,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
745745
#ifdef WIN32
746746
return 0;
747747
#else
748-
char pwdbuf[sizeof(struct passwd)];
748+
char pwdbuf[BUFSIZ];
749749
struct passwd pwdstr;
750750
struct passwd *pwd = NULL;
751751
struct stat buf,
@@ -952,7 +952,7 @@ initialize_SSL(PGconn *conn)
952952
{
953953
#ifndef WIN32
954954
struct stat buf;
955-
char pwdbuf[sizeof(struct passwd)];
955+
char pwdbuf[BUFSIZ];
956956
struct passwd pwdstr;
957957
struct passwd *pwd = NULL;
958958
char fnbuf[MAXPGPATH];

src/port/getaddrinfo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Copyright (c) 2003, PostgreSQL Global Development Group
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/port/getaddrinfo.c,v 1.14 2004/09/27 23:39:14 momjian Exp $
15+
* $PostgreSQL: pgsql/src/port/getaddrinfo.c,v 1.15 2004/09/28 00:07:01 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -85,7 +85,7 @@ getaddrinfo(const char *node, const char *service,
8585

8686
#ifdef FRONTEND
8787
struct hostent hpstr;
88-
char buf[sizeof(struct hostent)];
88+
char buf[BUFSIZ];
8989
int herrno = 0;
9090

9191
pqGethostbyname(node, &hpstr, buf, sizeof(buf),

src/port/thread.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
99
*
10-
* $PostgreSQL: pgsql/src/port/thread.c,v 1.27 2004/09/27 23:39:14 momjian Exp $
10+
* $PostgreSQL: pgsql/src/port/thread.c,v 1.28 2004/09/28 00:07:01 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -103,13 +103,15 @@ pqGetpwuid(uid_t uid, struct passwd * resultbuf, char *buffer,
103103
/* POSIX version */
104104
getpwuid_r(uid, resultbuf, buffer, buflen, result);
105105
#else
106+
106107
/*
107108
* Early POSIX draft of getpwuid_r() returns 'struct passwd *'.
108109
* getpwuid_r(uid, resultbuf, buffer, buflen)
109110
*/
110111
*result = getpwuid_r(uid, resultbuf, buffer, buflen);
111112
#endif
112113
#else
114+
113115
/* no getpwuid_r() available, just use getpwuid() */
114116
*result = getpwuid(uid);
115117
#endif

0 commit comments

Comments
 (0)