aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/iobuf.c7
-rw-r--r--common/sysutils.c6
-rw-r--r--common/sysutils.h2
3 files changed, 9 insertions, 6 deletions
diff --git a/common/iobuf.c b/common/iobuf.c
index 2504fb718..2752e3937 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -542,8 +542,8 @@ file_filter (void *opaque, int control, iobuf_t chain, byte * buf,
{
if (size && !WriteFile (f, p, nbytes, &n, NULL))
{
- int ec = (int) GetLastError ();
- rc = gpg_error_from_errno (ec);
+ int ec = gnupg_w32_set_errno (-1);
+ rc = gpg_error_from_syserror ();
log_error ("%s: write error: %s (ec=%d)\n",
a->fname, gpg_strerror (rc), ec);
break;
@@ -820,7 +820,8 @@ sock_filter (void *opaque, int control, iobuf_t chain, byte * buf,
if (n == SOCKET_ERROR)
{
int ec = (int) WSAGetLastError ();
- rc = gpg_error_from_errno (ec);
+ gnupg_w32_set_errno (ec);
+ rc = gpg_error_from_syserror ();
log_error ("socket write error: ec=%d\n", ec);
break;
}
diff --git a/common/sysutils.c b/common/sysutils.c
index 7676ab74a..0cd5f49f2 100644
--- a/common/sysutils.c
+++ b/common/sysutils.c
@@ -319,15 +319,17 @@ map_w32_to_errno (DWORD w32_err)
#endif /*HAVE_W32_SYSTEM*/
-/* Set ERRNO from the Windows error. EC may be -1 to use the last error. */
+/* Set ERRNO from the Windows error. EC may be -1 to use the last
+ * error. Returns the Windows error code. */
#ifdef HAVE_W32_SYSTEM
-void
+int
gnupg_w32_set_errno (int ec)
{
/* FIXME: Replace by gpgrt_w32_set_errno. */
if (ec == -1)
ec = GetLastError ();
_set_errno (map_w32_to_errno (ec));
+ return ec;
}
#endif /*HAVE_W32_SYSTEM*/
diff --git a/common/sysutils.h b/common/sysutils.h
index e22156b0a..d33e9c16c 100644
--- a/common/sysutils.h
+++ b/common/sysutils.h
@@ -107,7 +107,7 @@ int gnupg_inotify_has_name (int fd, const char *name);
#ifdef HAVE_W32_SYSTEM
-void gnupg_w32_set_errno (int ec);
+int gnupg_w32_set_errno (int ec);
void *w32_get_user_sid (void);
#include "../common/w32help.h"