Subject: bug#18458: Wrapper binary (.libs/lt-PROG.c) corrupts wide character arguments

From: Pavel Raiskup <[email-masked]>
Date: Fri, 12 Sep 2014 10:25:52 +0200

Hello,

recently I got a bug report in Fedora:
https://bugzilla.redhat.com/show_bug.cgi?id=1124436
Short summary:  On windows, the 'argv' in main() function is filled
by "preprocessed" content.  When `./wrapper.exe I ♥ lt`, the argv gets
filled by ["./wrapper.exe", "I", "?", "lt"].  Libtool wrapper parses this
argv[] content and based on this broken arguments it spawns the original
binary.  That way, original binary has different arguments and it
complicates testing, for example.

I tried to look at how it is done in the wrapper;  and I believe the
possible fix is non-trivial enough.  We need probably use the
GetcommandLineW and CommandLineToArgvW functions to obtain wide version of
argv.  That way, however, after removing --lt* arguments, you need to
escape the wide argv same way as for non-wide version (and pass it into
the _wspawnv call, instead of _spawnv).  I am not familiar with windows
api, so if you see that there is simpler/better solution, please say.

Firstly, I would like to know whether upstream is interested in such fix
and whether there is somebody interested in patch-review.  Secondly, TBH,
I'm not perfect example of guy to do such change (I could give it a try,
thought, through wine the problem seems to be reproducible).  If there was
somebody familiar with windows who wanted to write the patch, I would be
glad to do the review and testing.

Thanks for ideas!
Pavel