Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Windows CI failures. #2143

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/windows-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ jobs:
cmake -B build -G "Visual Studio 16 2019" \
-A ${{ matrix.arch.name }} \
-T ${{ matrix.toolset }} \
-DENABLE_SANITIZERS=yes \
-DBUILD_SHARED_LIBS=${{ matrix.shared_libs}} \
-DCRYPTO_BACKEND=${{ matrix.backend }} \
-DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_DIR }}/scripts/buildsystems/vcpkg.cmake .
Expand All @@ -152,6 +153,7 @@ jobs:
cmake -B build -G "Visual Studio 16 2019" \
-A ${{ matrix.arch.name }} \
-T ${{ matrix.toolset }} \
-DENABLE_SANITIZERS=yes \
-DBUILD_SHARED_LIBS=${{ matrix.shared_libs}} \
-DCRYPTO_BACKEND=${{ matrix.backend }} \
-DCMAKE_PREFIX_PATH=${{ env.VCPKG_DIR }}/installed/${{ matrix.arch.triplet }} .
Expand All @@ -172,4 +174,4 @@ jobs:
export PATH=${{ env.VCPKG_DIR_U }}/installed/${{ matrix.arch.triplet }}/bin:$PATH
mkdir -p "build/Testing/Temporary"
cp "cmake/CTestCostData.txt" "build/Testing/Temporary"
ctest --parallel ${{ env.CORES }} --test-dir build -C Release --output-on-failure
ctest --parallel ${{ env.CORES }} --test-dir build -C Release -V
13 changes: 8 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,14 @@ endif()

# sanitizers
if (ENABLE_SANITIZERS)
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(FATAL_ERROR "Sanitizers have only been tested with the clang compiler.")
endif()
add_compile_options(-fsanitize=leak,address,undefined -fno-omit-frame-pointer -fno-common -O1)
link_libraries(-fsanitize=leak,address,undefined)
#if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# message(FATAL_ERROR "Sanitizers have only been tested with the clang compiler.")
#endif()
#add_compile_options(-fsanitize=leak,address,undefined -fno-omit-frame-pointer -fno-common -O1)
#link_libraries(-fsanitize=leak,address,undefined)
add_compile_options(-fsanitize=address /Zi /MT)
add_link_options(/DEBUG)
#link_libraries(-fsanitize=address)
endif()

# adoc for man generation
Expand Down
15 changes: 14 additions & 1 deletion src/lib/crypto/symmetric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ pgp_cipher_aead_init(pgp_crypt_t * crypt,
RNP_LOG("failed to get update granularity");
return false;
}
RNP_LOG("initialized aead %p, granularity %zu.", crypt->aead.obj, crypt->aead.granularity);

return true;
}
Expand Down Expand Up @@ -548,10 +549,12 @@ pgp_cipher_aead_update(pgp_crypt_t *crypt, uint8_t *out, const uint8_t *in, size
return false;
}

RNP_LOG("calling botan_cipher_update() on %p with %zu.", crypt->aead.obj, len);
if (botan_cipher_update(crypt->aead.obj, 0, out, len, &outwr, in, len, &inread) != 0) {
RNP_LOG("aead update failed");
return false;
}
RNP_LOG("done");

if ((outwr != len) || (inread != len)) {
RNP_LOG("wrong aead usage");
Expand All @@ -564,7 +567,9 @@ pgp_cipher_aead_update(pgp_crypt_t *crypt, uint8_t *out, const uint8_t *in, size
void
pgp_cipher_aead_reset(pgp_crypt_t *crypt)
{
RNP_LOG("calling botan_cipher_reset() on %p.", crypt->aead.obj);
botan_cipher_reset(crypt->aead.obj);
RNP_LOG("done");
}

bool
Expand All @@ -577,15 +582,20 @@ pgp_cipher_aead_finish(pgp_crypt_t *crypt, uint8_t *out, const uint8_t *in, size

if (crypt->aead.decrypt) {
size_t datalen = len - crypt->aead.taglen;
std::vector<uint8_t> invec(in, in + len);
std::vector<uint8_t> outvec(len);
/* for decryption we should have tag for the final update call */
RNP_LOG("calling botan_cipher_update() on %p with %zu.", crypt->aead.obj, len);
res =
botan_cipher_update(crypt->aead.obj, flags, out, datalen, &outwr, in, len, &inread);
botan_cipher_update(crypt->aead.obj, flags, outvec.data(), outvec.size(), &outwr, invec.data(), invec.size(), &inread);
RNP_LOG("done: res %d, consumed %zu, written %zu", res, inread, outwr);
if (res != 0) {
if (res != BOTAN_FFI_ERROR_BAD_MAC) {
RNP_LOG("aead finish failed: %d", res);
}
return false;
}
memcpy(out, outvec.data(), datalen);

if ((outwr != datalen) || (inread != len)) {
RNP_LOG("wrong decrypt aead finish usage");
Expand All @@ -606,14 +616,17 @@ pgp_cipher_aead_finish(pgp_crypt_t *crypt, uint8_t *out, const uint8_t *in, size
}
}

RNP_LOG("calling pgp_cipher_aead_reset()");
pgp_cipher_aead_reset(crypt);
RNP_LOG("done");
return true;
}

void
pgp_cipher_aead_destroy(pgp_crypt_t *crypt)
{
if (crypt->aead.obj) {
RNP_LOG("calling botan_cipher_destroy() on %p", crypt->aead.obj);
botan_cipher_destroy(crypt->aead.obj);
}
memset(crypt, 0x0, sizeof(*crypt));
Expand Down
2 changes: 2 additions & 0 deletions src/lib/crypto/symmetric.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,14 @@ struct pgp_crypt_aead_param_t {

/** pgp_crypt_t */
typedef struct pgp_crypt_t {
uint8_t dummy1[40000];
union {
struct pgp_crypt_cfb_param_t cfb;
#if defined(ENABLE_AEAD)
struct pgp_crypt_aead_param_t aead;
#endif
};
uint8_t dummy2[40000];

pgp_symm_alg_t alg;
size_t blocksize;
Expand Down
3 changes: 3 additions & 0 deletions src/lib/rnp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3132,14 +3132,17 @@ rnp_verify_dest_provider(pgp_parse_handler_t *handler,
const char * filename,
uint32_t mtime)
{
RNP_LOG("here");
rnp_op_verify_t op = (rnp_op_verify_t) handler->param;
if (!op->output) {
RNP_LOG("here");
return false;
}
*dst = &(op->output->dst);
*closedst = false;
op->filename = filename ? std::string(filename) : "";
op->file_mtime = mtime;
RNP_LOG("here");
return true;
}

Expand Down
12 changes: 11 additions & 1 deletion src/librepgp/stream-common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,18 @@
src_read(pgp_source_t *src, void *buf, size_t len, size_t *readres)
{
size_t left = len;
size_t read;
size_t read = 0;
pgp_source_cache_t *cache = src->cache;
bool readahead = cache ? cache->readahead : false;

if (src->error) {
RNP_LOG("read error");
return false;
}

if (src->eof || (len == 0)) {
*readres = 0;
RNP_LOG("read eof");
return true;
}

Expand Down Expand Up @@ -96,11 +98,14 @@
// If there is no cache or chunk is larger then read directly
if (!src->read(src, buf, left, &read)) {
src->error = 1;
RNP_LOG("here");
return false;
}
// RNP_LOG("here: %p %zu", src->read, read);

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
if (!read) {
src->eof = 1;
len = len - left;
RNP_LOG("here: %zu", len);
goto finish;
}
left -= read;
Expand All @@ -109,11 +114,14 @@
// Try to fill the cache to avoid small reads
if (!src->read(src, &cache->buf[0], sizeof(cache->buf), &read)) {
src->error = 1;
RNP_LOG("here");
return false;
}
// RNP_LOG("here: %p %zu", src->read, read);

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
if (!read) {
src->eof = 1;
len = len - left;
RNP_LOG("here: %zu", len);
goto finish;
} else if (read < left) {
memcpy(buf, &cache->buf[0], read);
Expand All @@ -133,6 +141,7 @@
if (src->knownsize && (src->readb == src->size)) {
src->eof = 1;
}
//RNP_LOG("read bytes: %zu", len);

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
*readres = len;
return true;
}
Expand Down Expand Up @@ -386,6 +395,7 @@
if (rres < 0) {
return false;
}
RNP_LOG("%zu from %zu", (size_t) rres, len);
*readres = rres;
return true;
}
Expand Down
Loading
Loading