diff options
author | Saturn&Eric <[email protected]> | 2023-03-31 21:27:08 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2023-03-31 21:27:08 +0000 |
commit | 3cb863592a548edc074dde045493e0f83e5d694a (patch) | |
tree | 242534c257e723f49080428db22118c75706e233 /src/core/function | |
parent | Merge pull request #91 from saturneric/dev/2.0.10/main (diff) | |
parent | feat: add project security document (diff) | |
download | GpgFrontend-2.1.0.tar.gz GpgFrontend-2.1.0.zip |
Merge pull request #93 from saturneric/dev/2.0.10/mainv2.1.0
Develop 2.1.0.2
Diffstat (limited to 'src/core/function')
-rw-r--r-- | src/core/function/ArchiveFileOperator.cpp | 15 | ||||
-rw-r--r-- | src/core/function/CharsetOperator.cpp | 6 | ||||
-rw-r--r-- | src/core/function/aes/aes_ssl_cbc.cpp | 4 |
3 files changed, 6 insertions, 19 deletions
diff --git a/src/core/function/ArchiveFileOperator.cpp b/src/core/function/ArchiveFileOperator.cpp index 04c9326f..8aad0500 100644 --- a/src/core/function/ArchiveFileOperator.cpp +++ b/src/core/function/ArchiveFileOperator.cpp @@ -136,8 +136,6 @@ void GpgFrontend::ArchiveFileOperator::CreateArchive( } for (;;) { - bool needcr = false; - entry = archive_entry_new(); r = archive_read_next_header2(disk, entry); @@ -149,15 +147,6 @@ void GpgFrontend::ArchiveFileOperator::CreateArchive( } archive_read_disk_descend(disk); -#ifdef WINDOWS - auto entry_path = - QString::fromStdWString(std::wstring(archive_entry_pathname_w(entry))) - .toUtf8() - .toStdString(); -#else - auto entry_path = std::string(archive_entry_pathname_utf8(entry)); -#endif - SPDLOG_DEBUG("Adding: {} size: {} bytes: {} file type: {}", archive_entry_pathname_utf8(entry), archive_entry_size(entry), archive_entry_filetype(entry)); @@ -201,7 +190,6 @@ void GpgFrontend::ArchiveFileOperator::ExtractArchive( struct archive *a; struct archive *ext; struct archive_entry *entry; - int r; a = archive_read_new(); ext = archive_write_disk_new(); @@ -241,8 +229,9 @@ void GpgFrontend::ArchiveFileOperator::ExtractArchive( archive_error_string(a)); throw std::runtime_error("archive_read_open_filename() failed"); } + for (;;) { - r = archive_read_next_header(a, &entry); + int r = archive_read_next_header(a, &entry); if (r == ARCHIVE_EOF) break; if (r != ARCHIVE_OK) { SPDLOG_ERROR("archive_read_next_header() failed: {}", diff --git a/src/core/function/CharsetOperator.cpp b/src/core/function/CharsetOperator.cpp index 0e40e317..72c5e72b 100644 --- a/src/core/function/CharsetOperator.cpp +++ b/src/core/function/CharsetOperator.cpp @@ -117,12 +117,10 @@ bool GpgFrontend::CharsetOperator::Convert2Utf8(const std::string &buffer, if (status == U_BUFFER_OVERFLOW_ERROR) { status = U_ZERO_ERROR; - target_limit = target_capacity + 1; out_buffer.clear(); out_buffer.resize(target_capacity); - target_capacity = - ucnv_convert(from_encode.c_str(), to_encode.c_str(), out_buffer.data(), - out_buffer.size(), buffer.data(), buffer.size(), &status); + ucnv_convert(from_encode.c_str(), to_encode.c_str(), out_buffer.data(), + out_buffer.size(), buffer.data(), buffer.size(), &status); } if (U_FAILURE(status)) { diff --git a/src/core/function/aes/aes_ssl_cbc.cpp b/src/core/function/aes/aes_ssl_cbc.cpp index 88a54baa..3aa80ef5 100644 --- a/src/core/function/aes/aes_ssl_cbc.cpp +++ b/src/core/function/aes/aes_ssl_cbc.cpp @@ -59,7 +59,7 @@ uint8_t *aes_256_cbc_encrypt(EVP_CIPHER_CTX *e, uint8_t *plaintext, int *len) { /* max ciphertext len for a n bytes of plaintext is n + AES_BLOCK_SIZE -1 * bytes */ int c_len = *len + AES_BLOCK_SIZE, f_len = 0; - auto *ciphertext = (uint8_t *)malloc(c_len); + auto *ciphertext = static_cast<uint8_t *>(malloc(c_len)); /* allows reusing of 'e' for multiple encryption cycles */ EVP_EncryptInit_ex(e, nullptr, nullptr, nullptr, nullptr); @@ -86,7 +86,7 @@ uint8_t *aes_256_cbc_encrypt(EVP_CIPHER_CTX *e, uint8_t *plaintext, int *len) { uint8_t *aes_256_cbc_decrypt(EVP_CIPHER_CTX *e, uint8_t *ciphertext, int *len) { /* plaintext will always be equal to or lesser than length of ciphertext*/ int p_len = *len, f_len = 0; - auto *plaintext = (uint8_t *)malloc(p_len); + auto *plaintext = static_cast<uint8_t *>(malloc(p_len)); EVP_DecryptInit_ex(e, nullptr, nullptr, nullptr, nullptr); EVP_DecryptUpdate(e, plaintext, &p_len, ciphertext, *len); |