P
Piotr Klaban
Hi,
Does anyone know how to properly recorgnize STDIN/STDOUT
argument given to the perl module function?
I can not find the easy answer on the web and in docs.
Maybe someone can help me?
I have the following in my module (from CPAN) MIME::Fast (Fast/Part.xs):
184 void
185 g_mime_part_set_content(mime_part, svmixed)
186 MIME::Fast:
art mime_part
187 SV * svmixed
188 PREINIT:
189 char * data;
190 STRLEN len;
191 SV* svval;
192 GMimeStream *mime_stream = NULL;
193 GMimeDataWrapper *mime_data_wrapper = NULL;
194 svtype svvaltype;
195 CODE:
196 svval = svmixed;
197 if (SvROK(svmixed)) {
[...]
213 svval = SvRV(svmixed);
214 }
215 svvaltype = SvTYPE(svval);
216
217 if (svvaltype == SVt_PVGV) { // possible FILE * handle
218 PerlIO *pio;
219 FILE *fp;
220 int fd;
221
222 pio = IoIFP(sv_2io(svval));
[...]
242 } else if (svvaltype == SVt_PVMG) {
// possible STDIN/STDOU
243 int fd0 = (int)SvIV( svval );
244 int fd;
245
246 if (fd0 < 0 || (fd = dup(fd0)) == -1)
247 croak("MIME::Fast:
art::set_content: Can not
duplicate a FILE pointer");
248
249 mime_stream = g_mime_stream_fs_new(fd);
[...]
258 } else if (SvPOK(svval)) {
259 data = (char *)SvPV(svval, len);
260 g_mime_part_set_content(mime_part, data, len);
261 } else {
262 croak("mime_set_content: Unknown type: %d", (int)svvaltype);
263 }
The problem is in line 243 when the magic string is passed to the function
(e.g. in perl -wT mode any "my $string = '';" is tainted, and the taintness
is located into the magic.
It seems that I need something different to recognize e.g. \*STDIN.
Maybe someone can point me to the docs or example code.
Best regards,
Does anyone know how to properly recorgnize STDIN/STDOUT
argument given to the perl module function?
I can not find the easy answer on the web and in docs.
Maybe someone can help me?
I have the following in my module (from CPAN) MIME::Fast (Fast/Part.xs):
184 void
185 g_mime_part_set_content(mime_part, svmixed)
186 MIME::Fast:
187 SV * svmixed
188 PREINIT:
189 char * data;
190 STRLEN len;
191 SV* svval;
192 GMimeStream *mime_stream = NULL;
193 GMimeDataWrapper *mime_data_wrapper = NULL;
194 svtype svvaltype;
195 CODE:
196 svval = svmixed;
197 if (SvROK(svmixed)) {
[...]
213 svval = SvRV(svmixed);
214 }
215 svvaltype = SvTYPE(svval);
216
217 if (svvaltype == SVt_PVGV) { // possible FILE * handle
218 PerlIO *pio;
219 FILE *fp;
220 int fd;
221
222 pio = IoIFP(sv_2io(svval));
[...]
242 } else if (svvaltype == SVt_PVMG) {
// possible STDIN/STDOU
243 int fd0 = (int)SvIV( svval );
244 int fd;
245
246 if (fd0 < 0 || (fd = dup(fd0)) == -1)
247 croak("MIME::Fast:
duplicate a FILE pointer");
248
249 mime_stream = g_mime_stream_fs_new(fd);
[...]
258 } else if (SvPOK(svval)) {
259 data = (char *)SvPV(svval, len);
260 g_mime_part_set_content(mime_part, data, len);
261 } else {
262 croak("mime_set_content: Unknown type: %d", (int)svvaltype);
263 }
The problem is in line 243 when the magic string is passed to the function
(e.g. in perl -wT mode any "my $string = '';" is tainted, and the taintness
is located into the magic.
It seems that I need something different to recognize e.g. \*STDIN.
Maybe someone can point me to the docs or example code.
Best regards,