[Pkg-gnupg-commit] [libassuan] 320/437: 2010-06-11 Marcus Brinkmann <marcus at g10code.de>

Eric Dorland eric at moszumanska.debian.org
Fri May 22 05:33:58 UTC 2015


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository libassuan.

commit 9f4ec52c0e93f708f66363f45f99baa2092cf44b
Author: Marcus Brinkmann <mb at g10code.com>
Date:   Thu Jun 10 23:09:32 2010 +0000

    2010-06-11  Marcus Brinkmann  <marcus at g10code.de>
    
    	* assuan-handler.c (std_handler_input,
    	std_handler_output) [HAVE_W32CE_SYSTEM]: Finish the pipe.  We must
    	do this here, because otherwise assuan_close_input_fd() and
    	assuan_close_output_fd() can't work.
    	* system-w32ce.c (_assuan_w32ce_finish_pipe): Call SetLastError in
    	error case.
    	(__assuan_close): Save WSAGetLastError before trashing it!
    	Otherwise handle is never closed and GPGME hangs.
---
 src/ChangeLog        | 11 +++++++++++
 src/assuan-handler.c | 24 +++++++++++++++++++++++-
 src/system-w32ce.c   | 13 ++++++++++---
 3 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index f78ac81..362f3f0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
+2010-06-11  Marcus Brinkmann  <marcus at g10code.de>
+
+	* assuan-handler.c (std_handler_input,
+	std_handler_output) [HAVE_W32CE_SYSTEM]: Finish the pipe.  We must
+	do this here, because otherwise assuan_close_input_fd() and
+	assuan_close_output_fd() can't work.
+	* system-w32ce.c (_assuan_w32ce_finish_pipe): Call SetLastError in
+	error case.
+	(__assuan_close): Save WSAGetLastError before trashing it!
+	Otherwise handle is never closed and GPGME hangs.
+
 2010-06-10  Marcus Brinkmann  <marcus at g10code.de>
 
 	* w32ce-add.h (ASSUAN_STDIN, ASSUAN_STDOUT): Define magic handle values.
diff --git a/src/assuan-handler.c b/src/assuan-handler.c
index 9bb3010..c19117f 100644
--- a/src/assuan-handler.c
+++ b/src/assuan-handler.c
@@ -264,6 +264,17 @@ std_handler_input (assuan_context_t ctx, char *line)
   rc = assuan_command_parse_fd (ctx, line, &fd);
   if (rc)
     return PROCESS_DONE (ctx, rc);
+
+#ifdef HAVE_W32CE_SYSTEM
+  oldfd = fd;
+  fd = _assuan_w32ce_finish_pipe ((int)fd, 0);
+  if (fd == INVALID_HANDLE_VALUE)
+    return PROCESS_DONE (ctx, set_error (ctx, GPG_ERR_ASS_PARAMETER,
+					 "rvid conversion failed"));
+  TRACE2 (ctx, ASSUAN_LOG_SYSIO, "std_handler_input", ctx,
+	  "turned RVID 0x%x into handle 0x%x", oldfd, fd);
+#endif
+
   if (ctx->input_notify_fnc)
     {
       oldfd = ctx->input_fd;
@@ -284,10 +295,21 @@ std_handler_output (assuan_context_t ctx, char *line)
 {
   gpg_error_t rc;
   assuan_fd_t fd, oldfd;
-
+  
   rc = assuan_command_parse_fd (ctx, line, &fd);
   if (rc)
     return PROCESS_DONE (ctx, rc);
+
+#ifdef HAVE_W32CE_SYSTEM
+  oldfd = fd;
+  fd = _assuan_w32ce_finish_pipe ((int)fd, 1);
+  if (fd == INVALID_HANDLE_VALUE)
+    return PROCESS_DONE (ctx, set_error (ctx, gpg_err_code_from_syserror (),
+					 "rvid conversion failed"));
+  TRACE2 (ctx, ASSUAN_LOG_SYSIO, "std_handler_output", ctx,
+	  "turned RVID 0x%x into handle 0x%x", oldfd, fd);
+#endif
+
   if (ctx->output_notify_fnc)
     {
       oldfd = ctx->output_fd;
diff --git a/src/system-w32ce.c b/src/system-w32ce.c
index a95fbf3..c201c47 100644
--- a/src/system-w32ce.c
+++ b/src/system-w32ce.c
@@ -159,7 +159,10 @@ _assuan_w32ce_finish_pipe (int rvid, int write_end)
   HANDLE hd;
 
   if (!rvid)
-    return INVALID_HANDLE_VALUE;
+    {
+      SetLastError (ERROR_INVALID_HANDLE);
+      return INVALID_HANDLE_VALUE;
+    }
 
   hd = CreateFile (L"GPG1:", write_end? GENERIC_WRITE : GENERIC_READ,
                    FILE_SHARE_READ | FILE_SHARE_WRITE,
@@ -259,9 +262,13 @@ int
 __assuan_close (assuan_context_t ctx, assuan_fd_t fd)
 {
   int rc = closesocket (HANDLE2SOCKET(fd));
+  int err = WSAGetLastError ();
+
+  /* Note that gpg_err_set_errno on Windows CE overwrites
+     WSAGetLastError() (via SetLastError()).  */
   if (rc)
-    gpg_err_set_errno ( _assuan_sock_wsa2errno (WSAGetLastError ()) );
-  if (rc && WSAGetLastError () == WSAENOTSOCK)
+    gpg_err_set_errno (_assuan_sock_wsa2errno (err));
+  if (rc && err == WSAENOTSOCK)
     {
       rc = CloseHandle (fd);
       if (rc)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/libassuan.git



More information about the Pkg-gnupg-commit mailing list