Skip to content

Commit

Permalink
Don't check pointers for zero length buffers
Browse files Browse the repository at this point in the history
It's perfectly fine to give a NULL pointer if the length has explicitly
been specified as zero.
  • Loading branch information
CendioOssman committed May 20, 2024
1 parent 3db859e commit 763cf8b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions common/rfb/obfuscate.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ std::string rfb::deobfuscate(const uint8_t *data, size_t len)
{
char buf[9];

assert(data != NULL);

if (len != 8)
throw rdr::Exception("bad obfuscated password length");

assert(data != NULL);

deskey(d3desObfuscationKey, DE1);
des((uint8_t*)data, (uint8_t*)buf);
buf[8] = 0;
Expand Down
4 changes: 2 additions & 2 deletions common/rfb/util.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ namespace rfb {

bool hexToBin(const char* in, size_t inlen,
uint8_t* out, size_t outlen) {
assert(in);
assert(out);
assert(in || inlen == 0);
assert(out || outlen == 0);

if (inlen & 1)
return false;
Expand Down

0 comments on commit 763cf8b

Please sign in to comment.