Crashes on Windows if homedir is a windows drive letter
Closed, ResolvedPublic

Description

To reproduce:

c:\GnuPG\bin\gpgconf.exe --homedir c:\

Or:

set GNUPGHOME=c:
c:\GnuPG\bin\gpgconf.exe

The following does not crash:

set GNUPGHOME=c:\
c:\GnuPG\bin\gpgconf.exe

It's not only gpgconf that is crashing, there are also crashes of GpgSM and GnuPG itself.

aheinecke created this task.Jan 8 2018, 3:52 PM
aheinecke renamed this task from Crashes on Windows if homedir is a root drive to Crashes on Windows if homedir is a windows drive letter.
aa added a subscriber: aa.Jan 8 2018, 11:48 PM
aa added a comment.Jan 9 2018, 1:06 PM

my <output> was the following...

C:\Program Files (x86)\GnuPG\bin>gpgconf.exe --homedir c:\
gpg:OpenPGP:C%3a\Program Files (x86)\GnuPG\bin\gpg.exe
gpg-agent:Private Keys:C%3a\Program Files (x86)\GnuPG\bin\gpg-agent.exe
scdaemon:Smartcards:C%3a\Program Files (x86)\GnuPG\bin\scdaemon.exe
gpgsm:S/MIME:C%3a\Program Files (x86)\GnuPG\bin\gpgsm.exe
dirmngr:Network:C%3a\Program Files (x86)\GnuPG\bin\dirmngr.exe
pinentry:Passphrase Entry:C%3a\Program Files (x86)\GnuPG\..\GNU\GnuPG\pinentry.exe

C:\Program Files (x86)\GnuPG\bin>
werner added a comment.Jan 9 2018, 7:06 PM

Do you mean that GnuPG installed to c:/gnupg/bin/ crashed if that mentioned --homedir is given but it does work if it is installed at the standard place? Please run "gpgconf --version" in both ways.

ok,
well I run "it" on Power Shell ( Debuggable Package Manager ) and I got ..

PS C:\Program Files (x86)\GnuPG\bin> gpgconf --version
gpgconf (GnuPG) 2.0.30 (Gpg4win 2.3.3)
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
PS C:\Program Files (x86)\GnuPG\bin>

The install location does not have anything to do with that. I just always have my development installations directly under C: so that I can modify them without admin rights.

There is some randomness included. In another test it did not crash one time. I bet it's an uninitalized memory / string out of bounds read somewhere.

C:\Users\aheinecke>"c:\Program Files\GnuPG\bin\gpgconf.exe" --homedir c:
gpg:OpenPGP:c%3a\Program Files\GnuPG\bin\gpg.exe
gpg-agent:Geheime Schl├╝ssel:c%3a\Program Files\GnuPG\bin\gpg-agent.exe
scdaemon:Smartcard:c%3a\Program Files\GnuPG\bin\scdaemon.exe
gpgsm:S/MIME:c%3a\Program Files\GnuPG\bin\gpgsm.exe
dirmngr:Netz:c%3a\Program Files\GnuPG\bin\dirmngr.exe
pinentry:Passphrase Eingabe:c%3a\Program Files\GnuPG\..\Gpg4win\bin\pinentry.exe

C:\Users\aheinecke>"c:\Program Files\GnuPG\bin\gpgconf.exe" --homedir c:
-> Crash
C:\Users\aheinecke>"c:\Program Files\GnuPG\bin\gpgconf.exe" --homedir c:

Fatal error: Not enough space

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

C:\Users\aheinecke>"c:\Program Files\GnuPG\bin\gpgconf.exe" --version
gpgconf (GnuPG) 2.2.3
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

C:\Users\aheinecke>"c:\Program Files\GnuPG\bin\gpgconf.exe" --homedir c:
-> Crash
C:\Users\aheinecke>"c:\Program Files\GnuPG\bin\gpgconf.exe" --homedir c:
-> Crash
werner closed this task as Wontfix.Jan 10 2018, 9:15 AM

gnupg 2.0 reached EOL - there won't be any fixes.

aheinecke reopened this task as Open.Jan 10 2018, 9:32 AM

This is not with 2.0 but with 2.2.3 / current master.

Please just boot your Vista and try it ;-P

werner raised the priority of this task from Normal to High.Mar 26 2018, 10:20 AM
werner edited projects, added gnupg (gpg22); removed gnupg.

Under Wine it does not crash but returning an empty string is not a good idea in any case. The question is what to do with "c:". The usual meaning is to use the current directory of drive C. But that does not make much sense. Should we simply assume that "c:/" was meant?

In my opinion we should assume that c:/ was meant.

The most common usecase for this is IMO that a USB Stick is used for the GNUPGHOME.

werner added a comment.Apr 9 2018, 1:26 PM

I still can't reproduce the crash (on Vista).

Have you tried it multiple times? If it's unintialized memory access maybe you got lucky?

I just tried again and for me it crashes reliably.

werner added a comment.Apr 9 2018, 2:45 PM

Yes. However, I have tested a fix for the empty value.

c:/xxx/   -> c:/xxx
c:xxx       -> c:/xxx
c:xxx//    -> c:/xxx
/xxx        -> /xxx
/xxx//     -> /xxx
c:             -> c:/

Both with --homedir and GNUPGHOME

werner closed this task as Resolved.Apr 9 2018, 2:55 PM