Skip to content
Merged
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
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,27 @@ jobs:
sudo make install
make test

build-linux-sanitizers:
name: build-linux-sanitizers (asan, ubsan)
runs-on: ubuntu-26.04
steps:
- name: install-deps
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends cmake g++ libcppunit-dev libgnutls28-dev libgsasl-dev libicu-dev make pkg-config
- name: clone-vmime
uses: actions/checkout@v4
- name: buildall
env:
ASAN_OPTIONS: detect_leaks=1
LSAN_OPTIONS: suppressions=${{ github.workspace }}/tests/lsan.supp
UBSAN_OPTIONS: print_stacktrace=1
run: |
set -ex
cmake . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address,undefined" -DCMAKE_SHARED_LINKER_FLAGS="-fsanitize=address,undefined" -DVMIME_SENDMAIL_PATH:STRING="/usr/sbin/sendmail" -DVMIME_HAVE_TLS_SUPPORT:BOOL=ON -DVMIME_TLS_SUPPORT_LIB:STRING=gnutls -DVMIME_CHARSETCONV_LIB:STRING=icu -DVMIME_BUILD_TESTS=ON -DVMIME_BUILD_SAMPLES=OFF
make "-j$(nproc)"
ctest --output-on-failure

build-cygwin:
name: build-cygwin (openssl, iconv)
runs-on: windows-latest
Expand Down
12 changes: 4 additions & 8 deletions src/vmime/net/imap/IMAPParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4767,8 +4767,7 @@ class VMIME_EXPORT IMAPParser : public object {
template <class TYPE>
TYPE* get(string& line, size_t* currentPos) {

component* resp = new TYPE;
return internalGet <TYPE>(resp, line, currentPos);
return internalGet <TYPE>(std::unique_ptr <TYPE>(new TYPE), line, currentPos);
}

/** Parse a token which takes 2 arguments and advance.
Expand All @@ -4788,27 +4787,24 @@ class VMIME_EXPORT IMAPParser : public object {
template <class TYPE, class ARG1_TYPE, class ARG2_TYPE>
TYPE* getWithArgs(string& line, size_t* currentPos, ARG1_TYPE arg1, ARG2_TYPE arg2) {

component* resp = new TYPE(arg1, arg2);
return internalGet <TYPE>(resp, line, currentPos);
return internalGet <TYPE>(std::unique_ptr <TYPE>(new TYPE(arg1, arg2)), line, currentPos);
}

private:

template <class TYPE>
TYPE* internalGet(component* resp, string& line, size_t* currentPos) {
TYPE* internalGet(std::unique_ptr <TYPE> resp, string& line, size_t* currentPos) {

const size_t oldPos = *currentPos;

if (!resp->parse(*this, line, currentPos)) {

*currentPos = oldPos;

delete resp;

return NULL;
}

return static_cast <TYPE*>(resp);
return resp.release();
}

const string lastLine() const {
Expand Down
4 changes: 4 additions & 0 deletions tests/lsan.supp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# LeakSanitizer suppressions for leaks in third-party libraries

# Buffer allocated by glibc in newlocale(), called by std::locale and libp11-kit
leak:newlocale
14 changes: 7 additions & 7 deletions tests/net/imap/IMAPParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest)
parser->setTimeoutHandler(vmime::make_shared <testTimeoutHandler>());
parser->setStrict(false);

VASSERT_NO_THROW("non-strict mode", parser->readResponse(*tag));
VASSERT_NO_THROW("non-strict mode", std::unique_ptr <vmime::net::imap::IMAPParser::response>(parser->readResponse(*tag)));
}
}

Expand Down Expand Up @@ -113,7 +113,7 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest)
parser->setTimeoutHandler(toh);

parser->setStrict(false);
VASSERT_NO_THROW("non-strict mode", parser->readResponse(*tag));
VASSERT_NO_THROW("non-strict mode", std::unique_ptr <vmime::net::imap::IMAPParser::response>(parser->readResponse(*tag)));

++(*tag);

Expand Down Expand Up @@ -158,7 +158,7 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest)
parser->setTimeoutHandler(vmime::make_shared <testTimeoutHandler>());
parser->setStrict(false);

VASSERT_NO_THROW("non-strict mode", parser->readResponse(*tag));
VASSERT_NO_THROW("non-strict mode", std::unique_ptr <vmime::net::imap::IMAPParser::response>(parser->readResponse(*tag)));
}
}

Expand All @@ -181,7 +181,7 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest)
parser->setSocket(socket);
parser->setTimeoutHandler(toh);

VASSERT_NO_THROW("parse", parser->readResponse(*tag));
VASSERT_NO_THROW("parse", std::unique_ptr <vmime::net::imap::IMAPParser::response>(parser->readResponse(*tag)));
}

// Support for NIL boundary, for mail.ru IMAP server:
Expand Down Expand Up @@ -218,7 +218,7 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest)
parser->setTimeoutHandler(vmime::make_shared <testTimeoutHandler>());
parser->setStrict(false);

VASSERT_NO_THROW("non-strict mode", parser->readResponse(*tag));
VASSERT_NO_THROW("non-strict mode", std::unique_ptr <vmime::net::imap::IMAPParser::response>(parser->readResponse(*tag)));
}
}

Expand Down Expand Up @@ -253,7 +253,7 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest)
parser->setTimeoutHandler(vmime::make_shared <testTimeoutHandler>());
parser->setStrict(false);

VASSERT_NO_THROW("non-strict mode", parser->readResponse(*tag));
VASSERT_NO_THROW("non-strict mode", std::unique_ptr <vmime::net::imap::IMAPParser::response>(parser->readResponse(*tag)));
}
}

Expand Down Expand Up @@ -373,7 +373,7 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest)
parser->setTimeoutHandler(toh);
parser->setStrict(false);

VASSERT_NO_THROW("non-strict mode", parser->readResponse(*tag));
VASSERT_NO_THROW("non-strict mode", std::unique_ptr <vmime::net::imap::IMAPParser::response>(parser->readResponse(*tag)));
}
}

Expand Down
Loading