Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d31ff14

Browse files
committed
Fix memory overrun while setting ps status
1 parent 18c3000 commit d31ff14

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/backend/utils/init/globals.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.38 1999/10/08 04:28:48 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.39 1999/12/10 10:29:01 ishii Exp $
1111
*
1212
* NOTES
1313
* Globals used all over the place should be declared here and not
@@ -88,6 +88,13 @@ char *IndexedCatalogNames[] = {
8888
};
8989

9090

91+
/*
92+
* ps status buffer
93+
*/
94+
#ifndef linux
95+
char Ps_status_buffer[1024];
96+
#endif
97+
9198
/* ----------------
9299
* we just do a linear search now so there's no requirement that the list
93100
* be ordered. The list is so small it shouldn't make much difference.

src/include/utils/ps_status.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ char *ps_status_buffer = NULL
4848

4949
#else /* !linux */
5050

51-
extern const char **ps_status;
51+
extern char Ps_status_buffer[];
5252

53-
#define PS_DEFINE_BUFFER \
54-
const char **ps_status = NULL
53+
#define PS_DEFINE_BUFFER
5554

5655
#define PS_INIT_STATUS(argc, argv, execname, username, hostname, dbname) \
5756
{ \
@@ -61,18 +60,18 @@ const char **ps_status = NULL
6160
argv[1] = hostname; \
6261
argv[2] = username; \
6362
argv[3] = dbname; \
64-
ps_status = (const char **)&argv[4]; \
65-
for (i = 4; i < argc; i++) \
63+
argv[4] = Ps_status_buffer; \
64+
for (i = 5; i < argc; i++) \
6665
argv[i] = ""; /* blank them */ \
6766
}
6867

6968
#define PS_CLEAR_STATUS() \
70-
{ if (ps_status) *ps_status = ""; }
69+
{ Ps_status_buffer[0] = '\0'; }
7170

7271
#define PS_SET_STATUS(status) \
73-
{ if (ps_status) *ps_status = (status); }
72+
{ strcpy(Ps_status_buffer, (status)); }
7473

75-
#define PS_STATUS (ps_status ? *ps_status : "")
74+
#define PS_STATUS (Ps_status_buffer)
7675
#endif
7776

7877
#ifdef NO_PS_STATUS

0 commit comments

Comments
 (0)