Page MenuHome GnuPG

CreateFile(CONOUT$, ..) should not be used on win95/98/ME
Closed, ResolvedPublic

Description

Release: 1.2.4 and below

Environment

Intel; Win9x,Win ME; Release && Debug; not relevant

Description

Problem is described in emails to gnupg-users@ and gnupg-devel@gnupg.org. (Subject: bug using gpg in win98/me)

As i posted on the users mailinglist, i found a bug in
util/ttyio.c where on WIN32 platforms CreateFile is used to open
a console. An excerpt from:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/createfile.asp

Windows Me/98/95: The file system restricts CreateFile to creating or opening files; you cannot create or open the other
objects mentioned above. See the topics referenced in See Also at the end of this reference page for more information on
which of these facilities are available on these systems, and how to access them.

This includes the use of CONOUT$ and CONIN$ for opening a console.

Since most compilers on win32 prefectly understand the code used for unix/linux
to do the same, here is a patch. This should be tested against the prefered compiler
for gpg on win32. It works fine under Visual C 6.0 and 7.0.

The bug occures when you try to use gpg with pipes and try one of the
commands which cannot be used with --batch (e.g. --signkey) on win95/98 and ME.

As you will see, the patch mostly deletes code and instead uses the code
which is used on unix/linux. (killing a few #ifdef's is always nice ;)

I was not to sure whether to open stdout or stderr, but stderr was used
in batchmode for unix, so i used that.

How To Repeat

Create a program using pipes to communicate with gpg on win95/98/ME. Use a command which cannot be used with --batch, (e.g. --signkey )
It will bail out with a error code of 120 (function or method not supported)

Fix

See attached patch file. Should still be checked against other compilers. This patch is checked against visual c and works fine there.

Release Note

No fix, sorry.

Event Timeline

Using stderr as a replacedment for the console is not a proper solution. stderr might be different form the console.

It is funny that the W32 API call CreateFile works fine for the CONOUT$ device instead to fail unless the file descriptors are not connected to a console.

I don't know what to do. Given that old windows versions are not anymore that widespread and this is the first complain after years, I tend to ignore the problem for old Windows versions.

There is no easy way to fix it for those systems. Thus we
don't do it unless someone describes a proper way of doing so.