Skip to content

Commit

Permalink
Change some assertions to exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
CendioOssman committed Nov 22, 2024
1 parent 895b751 commit 213c12c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion common/rdr/AESInStream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#include <assert.h>

#include <stdexcept>

#include <rdr/AESInStream.h>

#ifdef HAVE_NETTLE
Expand All @@ -36,7 +38,7 @@ AESInStream::AESInStream(InStream* _in, const uint8_t* key,
else if (keySize == 256)
EAX_SET_KEY(&eaxCtx256, aes256_set_encrypt_key, aes256_encrypt, key);
else
assert(!"incorrect key size");
throw std::out_of_range("Incorrect key size");
}

AESInStream::~AESInStream() {}
Expand Down
6 changes: 4 additions & 2 deletions common/rdr/AESOutStream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#endif

#include <assert.h>
#include <rdr/Exception.h>

#include <stdexcept>

#include <rdr/AESOutStream.h>

#ifdef HAVE_NETTLE
Expand All @@ -39,7 +41,7 @@ AESOutStream::AESOutStream(OutStream* _out, const uint8_t* key,
else if (keySize == 256)
EAX_SET_KEY(&eaxCtx256, aes256_set_encrypt_key, aes256_encrypt, key);
else
assert(!"incorrect key size");
throw std::out_of_range("Incorrect key size");
}

AESOutStream::~AESOutStream()
Expand Down
4 changes: 3 additions & 1 deletion common/rfb/CSecurityRSAAES.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ bool CSecurityRSAAES::processMsg()
writeCredentials();
return true;
}
assert(!"unreachable");

throw std::logic_error("Invalid state");

return false;
}

Expand Down
4 changes: 3 additions & 1 deletion common/rfb/SSecurityRSAAES.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ bool SSecurityRSAAES::processMsg()
verifyPass();
return true;
}
assert(!"unreachable");

throw std::logic_error("Invalid state");

return false;
}

Expand Down

0 comments on commit 213c12c

Please sign in to comment.