Neil Conway wrote:
> On Mon, 2004-11-01 at 15:25, Bruce Momjian wrote:
> > Clarify coding of .exe patch
>
> This change looks wrong: sizeof(".exe") is 5, not 4 (it includes the NUL
> terminator).
Oh, I didn't realize they had the dot in there. Let me add "-1".
Thanks. Attached.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Index: src/port/path.c
===================================================================
RCS file: /cvsroot/pgsql/src/port/path.c,v
retrieving revision 1.39
diff -c -c -r1.39 path.c
*** src/port/path.c 1 Nov 2004 04:25:18 -0000 1.39
--- src/port/path.c 1 Nov 2004 04:45:55 -0000
***************
*** 195,202 ****
#if defined(__CYGWIN__) || defined(WIN32)
/* strip .exe suffix, regardless of case */
! if (strlen(nodir_name) > sizeof(EXE) &&
! pg_strcasecmp(nodir_name + strlen(nodir_name) - sizeof(EXE), EXE) == 0)
{
char *progname;
--- 195,202 ----
#if defined(__CYGWIN__) || defined(WIN32)
/* strip .exe suffix, regardless of case */
! if (strlen(nodir_name) > sizeof(EXE) - 1 &&
! pg_strcasecmp(nodir_name + strlen(nodir_name)-sizeof(EXE)-1, EXE) == 0)
{
char *progname;
***************
*** 206,212 ****
fprintf(stderr, "%s: out of memory\n", nodir_name);
exit(1);
}
! progname[strlen(progname) - sizeof(EXE)] = '\0';
nodir_name = progname;
}
#endif
--- 206,212 ----
fprintf(stderr, "%s: out of memory\n", nodir_name);
exit(1);
}
! progname[strlen(progname) - sizeof(EXE) - 1] = '\0';
nodir_name = progname;
}
#endif