Subject: | with z/OS perl 5.22 : mvsopen options clash with PerlIO_importFILE |
Date: | Mon, 19 Dec 2016 09:10:16 +0100 |
To: | bug-OS390-Stdio [...] rt.cpan.org |
From: | h.huzen [...] belastingdienst.nl |
Hi
I'm using OS390-Stdio-0.008 on z/OS perl 5.22. When using some specific
mvsopen open options, like "a, recfm=F", the module crashes.
In Stdio.xs the 'mode' string (with these special options) is also passed
to PerlIO_importFILE, which then crashes.
The solution is to dup the mode string, cut off the special options (at the
comma position) and pass that clean copy to PerlIO_importFile.
The original mode string is in the caller context and must not be modified.
See the code changes marked /*HH*/
void
mvsopen(name,mode)
char * name
char * mode
PROTOTYPE: @
CODE:
FILE * fp;
#ifdef USE_PERLIO
PerlIO * pio_fp;
SV *fh;
/* HH */
/* for a clean copy of mode */
char * dupmode;
char * p;
/* /HH */
#endif
fp = fopen(name,mode);
#ifdef USE_PERLIO
if (fp != Null(FILE *)) {
/* HH truncate mode, do not pass the fancy mvs modes to PerlIO functions*/
dupmode=strdup(mode);
for ( p=dupmode; *p; *p++ ) {
if (*p == ',' || *p == ' ') {
*p = '\0';
break;
}
}
pio_fp = PerlIO_importFILE(fp,dupmode);
free (dupmode);
/* pio_fp = PerlIO_importFILE(fp,mode); */ /* original code
*/
/* /HH */
fh = newFH(pio_fp,(mode[1] ? '+' : (mode[0] == 'r' ? '<' :
(mode[0] == 'a' ? 'a' : '>'))));
ST(0) = (fh ? sv_2mortal(fh) : &PL_sv_undef);
}
else { ST(0) = &PL_sv_undef; }
#else
if (fp != Nullfp) {
SV *fh = newFH(fp,(mode[1] ? '+' : (mode[0] == 'r' ? '<' :
(mode[0] == 'a' ? 'a' : '>'))));
ST(0) = (fh ? sv_2mortal(fh) : &PL_sv_undef);
}
else { ST(0) = &PL_sv_undef; }
#endif
Kind regards,
Harrie Huzen
------------------------------------------------------------------------
De Belastingdienst stelt e-mail niet open voor aanvragen, aangiften, bezwaarschriften, verzoeken, klachten, ingebrekestellingen en soortgelijke formele berichten.
Dit bericht is uitsluitend bestemd voor de geadresseerde. Het bericht kan vertrouwelijke informatie bevatten waarvoor de fiscale geheimhoudingsplicht geldt. Als u dit bericht per abuis hebt ontvangen, wordt u verzocht het te verwijderen en de afzender te informeren.
The Dutch Tax and Customs Administration does not accept filings, requests, appeals, complaints, notices of default or similar formal notices, sent by email.
This message is solely intended for the addressee. It may contain information that is confidential and legally privileged. If you are not the intended recipient please delete this message and notify the sender.