aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2023-05-23 12:50:22 +0000
committerWerner Koch <[email protected]>2023-05-24 10:13:56 +0000
commit42bea7de16e9dd64fefda7b46760b6c309393450 (patch)
treead8a5e3d67ebd59c307d097e3439db58a3a79a53
parentsm: Emit STATUS_FAILURE for non-implemented commands. (diff)
downloadgnupg-42bea7de16e9dd64fefda7b46760b6c309393450.tar.gz
gnupg-42bea7de16e9dd64fefda7b46760b6c309393450.zip
common,w32: Set a proper error code when creating an output file.
* common/iobuf.c (direct_open) [W32]: Set errno. (fd_cache_open): Ditto. --
-rw-r--r--common/iobuf.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/common/iobuf.c b/common/iobuf.c
index e088812a6..8da591046 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -311,6 +311,13 @@ direct_open (const char *fname, const char *mode, int mode700)
{
hfile = CreateFileW (wfname, da, sm, NULL, cd,
FILE_ATTRIBUTE_NORMAL, NULL);
+ if (hfile == INVALID_HANDLE_VALUE)
+ {
+ gnupg_w32_set_errno (-1);
+ if (DBG_IOBUF)
+ log_debug ("iobuf:direct_open '%s' CreateFile failed: %s\n",
+ fname, gpg_strerror (gpg_error_from_syserror()));
+ }
xfree (wfname);
}
else
@@ -426,8 +433,9 @@ fd_cache_open (const char *fname, const char *mode)
#ifdef HAVE_W32_SYSTEM
if (SetFilePointer (fp, 0, NULL, FILE_BEGIN) == 0xffffffff)
{
- log_error ("rewind file failed on handle %p: ec=%d\n",
- fp, (int) GetLastError ());
+ int ec = (int) GetLastError ();
+ log_error ("rewind file failed on handle %p: ec=%d\n", fp, ec);
+ gnupg_w32_set_errno (ec);
fp = GNUPG_INVALID_FD;
}
#else