Skip to content

Commit

Permalink
VS2010: Fix intermingled declarations and code
Browse files Browse the repository at this point in the history
  • Loading branch information
kiyolee committed Apr 12, 2022
1 parent 5e236b4 commit 2d41b80
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/zip_crypto_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ There is no #ifdef to control that, because this is working for all supported OS
bool
_zip_crypto_pbkdf2(const zip_uint8_t *key, zip_uint64_t key_length, const zip_uint8_t *salt, zip_uint16_t salt_length, zip_uint16_t iterations, zip_uint8_t *output, zip_uint16_t output_length) {
BCRYPT_ALG_HANDLE hAlgorithm = NULL;
bool result;

if (!BCRYPT_SUCCESS(BCryptOpenAlgorithmProvider(&hAlgorithm, BCRYPT_SHA1_ALGORITHM, NULL, BCRYPT_ALG_HANDLE_HMAC_FLAG))) {
return false;
}

bool result = BCRYPT_SUCCESS(BCryptDeriveKeyPBKDF2(hAlgorithm, (PUCHAR)key, (ULONG)key_length, (PUCHAR)salt, salt_length, iterations, output, output_length, 0));
result = BCRYPT_SUCCESS(BCryptDeriveKeyPBKDF2(hAlgorithm, (PUCHAR)key, (ULONG)key_length, (PUCHAR)salt, salt_length, iterations, output, output_length, 0));

BCryptCloseAlgorithmProvider(hAlgorithm, 0);

Expand Down
6 changes: 4 additions & 2 deletions lib/zip_source_file_win32_named.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ zip_source_file_operations_t _zip_source_file_win32_named_ops = {
static zip_int64_t
_zip_win32_named_op_commit_write(zip_source_file_context_t *ctx) {
zip_win32_file_operations_t *file_ops = (zip_win32_file_operations_t *)ctx->ops_userdata;
DWORD attributes;

if (!CloseHandle((HANDLE)ctx->fout)) {
zip_error_set(&ctx->error, ZIP_ER_WRITE, _zip_win32_error_to_errno(GetLastError()));
return -1;
}

DWORD attributes = file_ops->get_file_attributes(ctx->tmpname);
attributes = file_ops->get_file_attributes(ctx->tmpname);
if (attributes == INVALID_FILE_ATTRIBUTES) {
zip_error_set(&ctx->error, ZIP_ER_RENAME, _zip_win32_error_to_errno(GetLastError()));
return -1;
Expand Down Expand Up @@ -248,6 +249,7 @@ win32_named_open(zip_source_file_context_t *ctx, const char *name, bool temporar
DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_WRITE;
DWORD creation_disposition = OPEN_EXISTING;
DWORD file_attributes = FILE_ATTRIBUTE_NORMAL;
HANDLE h;

if (temporary) {
access = GENERIC_READ | GENERIC_WRITE;
Expand All @@ -256,7 +258,7 @@ win32_named_open(zip_source_file_context_t *ctx, const char *name, bool temporar
file_attributes = FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_TEMPORARY;
}

HANDLE h = file_ops->create_file(name, access, share_mode, security_attributes, creation_disposition, file_attributes, NULL);
h = file_ops->create_file(name, access, share_mode, security_attributes, creation_disposition, file_attributes, NULL);

if (h == INVALID_HANDLE_VALUE) {
zip_error_set(&ctx->error, ZIP_ER_OPEN, _zip_win32_error_to_errno(GetLastError()));
Expand Down
3 changes: 2 additions & 1 deletion lib/zip_source_pkware_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ decrypt_header(zip_source_t *src, struct trad_pkware *ctx) {
zip_uint8_t header[ZIP_CRYPTO_PKWARE_HEADERLEN];
struct zip_stat st;
zip_int64_t n;
bool ok;

if ((n = zip_source_read(src, header, ZIP_CRYPTO_PKWARE_HEADERLEN)) < 0) {
_zip_error_set_from_source(&ctx->error, src);
Expand All @@ -105,7 +106,7 @@ decrypt_header(zip_source_t *src, struct trad_pkware *ctx) {
* CRC - old PKWare way
*/

bool ok = false;
ok = false;

if (st.valid & ZIP_STAT_MTIME) {
unsigned short dostime, dosdate;
Expand Down

0 comments on commit 2d41b80

Please sign in to comment.