[svn] w32pth - r27 - trunk

svn author wk cvs at cvs.gnupg.org
Wed Oct 15 12:49:32 CEST 2008


Author: wk
Date: 2008-10-15 12:49:31 +0200 (Wed, 15 Oct 2008)
New Revision: 27

Modified:
   trunk/ChangeLog
   trunk/w32-pth.c
Log:
Fixed bogus error checking so that a closed pipe is properly detected.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-10-13 11:32:00 UTC (rev 26)
+++ trunk/ChangeLog	2008-10-15 10:49:31 UTC (rev 27)
@@ -1,3 +1,8 @@
+2008-10-15  Werner Koch  <wk at g10code.com>
+
+	* w32-pth.c (map_w32_to_errno): Return EPIPE.
+	(do_pth_write): Fix bogus error checking for WriteFile.
+
 2008-10-13  Werner Koch  <wk at g10code.com>
 
 	* pth.h (PTH_EVENT_HANDLE): New.  Note that this was orginally

Modified: trunk/w32-pth.c
===================================================================
--- trunk/w32-pth.c	2008-10-13 11:32:00 UTC (rev 26)
+++ trunk/w32-pth.c	2008-10-15 10:49:31 UTC (rev 27)
@@ -269,6 +269,9 @@
 
     case ERROR_NOT_ENOUGH_MEMORY:
       return ENOMEM;
+      
+    case ERROR_NO_DATA:
+      return EPIPE;
 
     default:
       return EIO;
@@ -672,16 +675,14 @@
 	  
 	  /* This is no real error because we first need to figure out
 	     if we have a handle or a socket.  */
-
-	  n = WriteFile ((HANDLE)fd, buffer, size, &nwrite, NULL);
-	  if (n == -1)
+	  if (!WriteFile ((HANDLE)fd, buffer, size, &nwrite, NULL))
 	    {
+	      n = -1;
+	      errno = map_w32_to_errno (GetLastError ());
 	      if (DBG_ERROR)
 		fprintf (dbgfp, "%s: pth_write(%d) failed in write: %s\n",
 			 log_get_prefix (NULL), fd,
 			 w32_strerror (strerr, sizeof strerr));
-	      n = -1;
-	      errno = map_w32_to_errno (GetLastError ());
 	    }
 	  else
 	    n = (int) nwrite;




More information about the Gnupg-commits mailing list