Date:

Tue Oct 3 21:04:41 PDT 1995

Description

The result from getopt() was getting incorrectly typecasted from int to char. This can cause core dumps on some systems (e.g. Irix 5.3).

Thanks to Robert Patrick, Andrew Martin, John Scott, and others for finding the problem.

Fix

Apply this patch.

===================================================================
RCS file: /usr/local/devel/pglite/cvs/src/backend/postmaster/postmaster.c,v
retrieving revision 1.21
diff -c -r1.21 postmaster.c
*** 1.21	1995/07/29 05:22:51
--- src/backend/postmaster/postmaster.c	1995/10/01 05:03:50
***************
*** 167,173 ****
  {
      extern int	NBuffers;	/* from buffer/bufmgr.c */
      extern bool	IsPostmaster;	/* from smgr/mm.c */
!     char	opt;
      char	*hostName;
      int		status;
      int		silentflag = 0;
--- 167,173 ----
  {
      extern int	NBuffers;	/* from buffer/bufmgr.c */
      extern bool	IsPostmaster;	/* from smgr/mm.c */
!     int	opt;
      char	*hostName;
      int		status;
      int		silentflag = 0;
===================================================================
RCS file: /usr/local/devel/pglite/cvs/src/backend/tcop/postgres.c,v
retrieving revision 1.32
diff -c -r1.32 postgres.c
*** 1.32	1995/08/01 20:25:56
--- src/backend/tcop/postgres.c 	1995/10/01 05:05:07
***************
*** 180,186 ****
  InteractiveBackend(char *inBuf)
  {
      String stuff = inBuf;		/* current place in input buffer */
!     char c;				/* character read from getc() */
      bool end = false;			/* end-of-input flag */
      bool backslashSeen = false;		/* have we seen a \ ? */
      
--- 180,186 ----
  InteractiveBackend(char *inBuf)
  {
      String stuff = inBuf;		/* current place in input buffer */
!     int c;				/* character read from getc() */
      bool end = false;			/* end-of-input flag */
      bool backslashSeen = false;		/* have we seen a \ ? */
      
***************
*** 197,203 ****
  	     *  characters until the \n.
  	     * ----------------
  	     */
! 	    while ( (c = (char) getc(stdin)) != EOF) {
  		if (c == '\n') {
  		    if (backslashSeen) {
  			stuff--;
--- 197,203 ----
  	     *  characters until the \n.
  	     * ----------------
  	     */
! 	    while ( (c = getc(stdin)) != EOF) {
  		if (c == '\n') {
  		    if (backslashSeen) {
  			stuff--;
***************
*** 213,219 ****
  		else
  		    backslashSeen = false;
  		
! 		*stuff++ = c;
  	    }
  	    
  	    if (c == EOF)
--- 213,219 ----
  		else
  		    backslashSeen = false;
  		
! 		*stuff++ = (char)c;
  	    }
  	    
  	    if (c == EOF)
***************
*** 223,230 ****
  	     *	otherwise read characters until EOF.
  	     * ----------------
  	     */
! 	    while ( (c = (char)getc(stdin)) != EOF )
! 		*stuff++ = c;
  	    
  	    if ( stuff == inBuf )
  		end = true;
--- 223,230 ----
  	     *	otherwise read characters until EOF.
  	     * ----------------
  	     */
! 	    while ( (c = getc(stdin)) != EOF )
! 		*stuff++ = (char)c;
  	    
  	    if ( stuff == inBuf )
  		end = true;