OSDN Git Service

Defend against overrun of ExtraOptions array --- strictly paranoia,
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 10 Jul 2004 23:29:16 +0000 (23:29 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 10 Jul 2004 23:29:16 +0000 (23:29 +0000)
since the person or script starting the postmaster has to be trusted
anyway.

src/backend/postmaster/postmaster.c

index 5d90880..ee93471 100644 (file)
@@ -37,7 +37,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.405 2004/06/24 21:02:55 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.406 2004/07/10 23:29:16 tgl Exp $
  *
  * NOTES
  *
@@ -450,8 +450,9 @@ PostmasterMain(int argc, char *argv[])
                                /*
                                 * Other options to pass to the backend on the command line
                                 */
-                               strcat(ExtraOptions, " ");
-                               strcat(ExtraOptions, optarg);
+                               snprintf(ExtraOptions + strlen(ExtraOptions),
+                                                sizeof(ExtraOptions) - strlen(ExtraOptions),
+                                                " %s", optarg);
                                break;
                        case 'p':
                                SetConfigOption("port", optarg, PGC_POSTMASTER, PGC_S_ARGV);