public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Perl: Cygwin::win_to_posix_path() fails; Possible memory corruption
@ 2017-11-16  9:45 Lando Nachtmann
  2017-11-16 19:39 ` Achim Gratz
  0 siblings, 1 reply; 2+ messages in thread
From: Lando Nachtmann @ 2017-11-16  9:45 UTC (permalink / raw)
  To: cygwin

Hello,

I have a problem using the Perl-integrated Cygwin path conversion methods. 
Below is my Perl bug report (#132443) created via perlbug for details. They suggested to file a bug against the XML::DOM module. But since it is a Cygwin-specific problem, I thought it is better to ask on the mailing list first.

Thanks,
Lando

This is a bug report for perl from ln@h0x.de,
generated with the help of perlbug 1.40 running under perl 5.26.1.

The Perl-integrated conversion function for Cygwin paths Cygwin::win_to_posix_path() is broken.
Tested with a path read from a XML file using XML::DOM, its output is faulty.
Depending on the setting, its output is empty, garbage or aborts with 'Out of memory'.
Most likely, there are some memory allocation issues.

To reproduce, please call script 'test.pl' with attached XML file 'test.xml' as argument.
Depending on used path to file (relative or absolute, Windows or POSIX style etc.), different types of failure appear.

+++ test.pl +++
#!/usr/bin/env perl

use XML::DOM;

print 'XML FILE (argument):>' . $ARGV[0] . "<\n";
my $xml_path = Cygwin::win_to_posix_path($ARGV[0]);
print 'XML FILE (converted):>' . $xml_path . "<\n";

my $parser = new XML::DOM::Parser();
my $dom_tree = $parser->parsefile($xml_path);
my $attr_path = $dom_tree->getDocumentElement()->getAttribute('attr');
print 'PATH FROM ATTRIBUTE:>' . $attr_path . "<\n";

my $win_attr_path = Cygwin::win_to_posix_path($attr_path);
print 'PATH FROM ATTRIBUTE (converted):>' . $win_attr_path . "<\n";

+++ test.xml +++
<?xml version="1.0" ?>
<Test attr="C:\Cygwin\usr\bin\ls.exe"></Test>

Please note that in my tests, only the path read from the XML is affected. Direct output of this
file before (broken) conversion shows no abnormality though. Therefore I am not sure if this bug
originates in Perl core or XML::DOM module.---
Flags:
category=core
severity=low
---
Site configuration information for perl 5.26.1:

Configured by ASSI at Tue Sep 26 18:57:14 CEST 2017.

Summary of my perl5 (revision 5 version 26 subversion 1) configuration:

Platform:
osname=cygwin
osvers=2.9.0(0.31853)
archname=i686-cygwin-threads-64int-multi
uname='cygwin_nt-6.3-wow cygwin 2.9.0(0.31853) 2017-09-12 10:41 i686 cygwin '
config_args='-des -Dprefix=/usr -Dmksymlinks -Darchname=i686-cygwin-threads-64int
-Dlibperl=cygperl5_26.dll -Dcc=gcc -Dld=g++ -Accflags=-ggdb -O2 -pipe
-Wimplicit-function-declaration
-fdebug-prefix-map=/mnt/share/maint/perl.x86/build=/usr/src/debug/perl-5.26.1-1
-fdebug-prefix-map=/mnt/share/maint/perl.x86/src/perl-5.26.1=/usr/src/debug/perl-5.26.1-1 -fwrapv'
hint=recommended
useposix=true
d_sigaction=define
useithreads=define
usemultiplicity=define
use64bitint=define
use64bitall=undef
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
bincompat5005=undef
Compiler:
cc='gcc'
ccflags ='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -D_GNU_SOURCE -ggdb -O2 -pipe
-Wimplicit-function-declaration
-fdebug-prefix-map=/mnt/share/maint/perl.x86/build=/usr/src/debug/perl-5.26.1-1
-fdebug-prefix-map=/mnt/share/maint/perl.x86/src/perl-5.26.1=/usr/src/debug/perl-5.26.1-1 -fwrapv
-fno-strict-aliasing -fstack-protector-strong -D_FORTIFY_SOURCE=2'
optimize='-O3'
cppflags='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -D_GNU_SOURCE -ggdb -O2 -pipe
-Wimplicit-function-declaration
-fdebug-prefix-map=/mnt/share/maint/perl.x86/build=/usr/src/debug/perl-5.26.1-1
-fdebug-prefix-map=/mnt/share/maint/perl.x86/src/perl-5.26.1=/usr/src/debug/perl-5.26.1-1 -fwrapv
-fno-strict-aliasing -fstack-protector-strong'
ccversion=''
gccversion='6.4.0'
gccosandvers=''
intsize=4
longsize=4
ptrsize=4
doublesize=8
byteorder=12345678
doublekind=3
d_longlong=define
longlongsize=8
d_longdbl=define
longdblsize=12
longdblkind=3
ivtype='long long'
ivsize=8
nvtype='double'
nvsize=8
Off_t='off_t'
lseeksize=8
alignbytes=8
prototype=define
Linker and Libraries:
ld='g++'
ldflags =' -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base
-fstack-protector-strong'
libpth=/usr/lib
libs=-lpthread -lgdbm -ldb -ldl -lcrypt -lgdbm_compat
perllibs=-lpthread -ldl -lcrypt
libc=/usr/lib/libcygwin.a
so=dll
useshrplib=true
libperl=cygperl5_26.dll
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs
dlext=dll
d_dlsymun=undef
ccdlflags=' '
cccdlflags=' '
lddlflags=' --shared -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base
-fstack-protector-strong'

Locally applied patches:
Cygwin: README
Cygwin: use auto-image-base instead of fixed DLL base address
Cygwin: modify hints
Cygwin: Configure correct libsearch
Cygwin: Configure correct libpth
Cygwin: Win32 correct UTF8 handling
Perl: File-Path-2.14 (fixes CVE2017-6512)

---
@INC for perl 5.26.1:
/usr/local/lib/perl5/site_perl/5.26/i686-cygwin-threads-64int
/usr/local/share/perl5/site_perl/5.26
/usr/lib/perl5/vendor_perl/5.26/i686-cygwin-threads-64int
/usr/share/perl5/vendor_perl/5.26
/usr/lib/perl5/5.26/i686-cygwin-threads-64int
/usr/share/perl5/5.26

---
Environment for perl 5.26.1:
HOME=/home/ln
LANG=en_US.UTF-8
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/usr/local/bin:/usr/bin:/cygdrive/c/ProgramData/Oracle/Java/javapath:/cygdrive/c/Windows/system
2:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShe
l/v1.0:/cygdrive/c/Program Files/Git/cmd:/cygdrive/c/Program Files/TortoiseGit/bin
PERL_BADLANG (unset)
SHELL=/bin/bash

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Perl: Cygwin::win_to_posix_path() fails; Possible memory corruption
  2017-11-16  9:45 Perl: Cygwin::win_to_posix_path() fails; Possible memory corruption Lando Nachtmann
@ 2017-11-16 19:39 ` Achim Gratz
  0 siblings, 0 replies; 2+ messages in thread
From: Achim Gratz @ 2017-11-16 19:39 UTC (permalink / raw)
  To: cygwin

Lando Nachtmann writes:
> I have a problem using the Perl-integrated Cygwin path conversion
> methods.

You might want to read the documentation again.  In short, don't feed it
UTF strings, it's not designed to handle them.

Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Factory and User Sound Singles for Waldorf Q+, Q and microQ:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-11-16 19:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-16  9:45 Perl: Cygwin::win_to_posix_path() fails; Possible memory corruption Lando Nachtmann
2017-11-16 19:39 ` Achim Gratz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).