Page MenuHome GnuPG

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.

Details

Version
2.2.3

Event Timeline

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.Jan 8 2018, 3:55 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>

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

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

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.

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.

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