Cleanup some Windows issues with open

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3491 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
alonbl 2008-04-25 11:51:03 +00:00
parent 104ff0ed66
commit 597bcd7635
1 changed files with 3 additions and 9 deletions

View File

@ -958,17 +958,11 @@ static void sign_data(CK_SLOT_ID slot, CK_SESSION_HANDLE session,
if (rv != CKR_OK)
p11_fatal("C_SignFinal", rv);
#ifdef _WIN32
if (opt_output == NULL)
fd = 1;
else if ((fd = open(opt_output, O_CREAT|O_TRUNC|O_WRONLY|O_BINARY, 0666)) < 0)
else if ((fd = open(opt_output, O_CREAT|O_TRUNC|O_WRONLY|O_BINARY, S_IRUSR|S_IWUSR)) < 0) {
util_fatal("failed to open %s: %m", opt_output);
#else
if (opt_output == NULL)
fd = 1;
else if ((fd = open(opt_output, O_CREAT|O_TRUNC|O_WRONLY, 0666)) < 0)
util_fatal("failed to open %s: %m", opt_output);
#endif /* _WIN32 */
}
r = write(fd, buffer, sig_len);
if (r < 0)
@ -1019,7 +1013,7 @@ static void hash_data(CK_SLOT_ID slot, CK_SESSION_HANDLE session)
if (opt_output == NULL)
fd = 1;
else if ((fd = open(opt_output, O_CREAT|O_TRUNC|O_WRONLY, 0666)) < 0)
else if ((fd = open(opt_output, O_CREAT|O_TRUNC|O_WRONLY|O_BINARY, S_IRUSR|S_IWUSR)) < 0)
util_fatal("failed to open %s: %m", opt_output);
r = write(fd, buffer, hash_len);