bool was_fdopen = FALSE;
bool in_raw = 0, in_crlf = 0, out_raw = 0, out_crlf = 0;
char *type = NULL;
- char mode[PERL_MODE_MAX]; /* stdio file mode ("r\0", "rb\0", "r+b\0" etc.) */
+ char mode[PERL_MODE_MAX]; /* file mode ("r\0", "rb\0", "ab\0" etc.) */
SV *namesv;
Zero(mode,sizeof(mode),char);
writing = 1;
#ifdef HAS_STRLCAT
if (out_raw)
- strlcat(mode, "b", PERL_MODE_MAX);
+ strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (out_crlf)
- strlcat(mode, "t", PERL_MODE_MAX);
+ strlcat(mode, "t", PERL_MODE_MAX - 1);
#else
if (out_raw)
strcat(mode, "b");
#ifdef HAS_STRLCAT
if (out_raw)
- strlcat(mode, "b", PERL_MODE_MAX);
+ strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (out_crlf)
- strlcat(mode, "t", PERL_MODE_MAX);
+ strlcat(mode, "t", PERL_MODE_MAX - 1);
#else
if (out_raw)
strcat(mode, "b");
mode[0] = 'r';
#ifdef HAS_STRLCAT
if (in_raw)
- strlcat(mode, "b", PERL_MODE_MAX);
+ strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (in_crlf)
- strlcat(mode, "t", PERL_MODE_MAX);
+ strlcat(mode, "t", PERL_MODE_MAX - 1);
#else
if (in_raw)
strcat(mode, "b");
#ifdef HAS_STRLCAT
if (in_raw)
- strlcat(mode, "b", PERL_MODE_MAX);
+ strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (in_crlf)
- strlcat(mode, "t", PERL_MODE_MAX);
+ strlcat(mode, "t", PERL_MODE_MAX - 1);
#else
if (in_raw)
strcat(mode, "b");
#ifdef HAS_STRLCAT
if (in_raw)
- strlcat(mode, "b", PERL_MODE_MAX);
+ strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (in_crlf)
- strlcat(mode, "t", PERL_MODE_MAX);
+ strlcat(mode, "t", PERL_MODE_MAX - 1);
#else
if (in_raw)
strcat(mode, "b");
if (*s == 'f') {
s++;
#ifdef HAS_STRLCPY
- strlcat(flags, "f", PERL_FLAGS_MAX);
+ strlcat(flags, "f", PERL_FLAGS_MAX - 2);
#else
strcat(flags,"f");
#endif