Skip to content

Commit

Permalink
fix bad mem access in bb64 decode routine
Browse files Browse the repository at this point in the history
fix bad mem access (found with valgrind), the fix is adapted
from Cinder's bug fix for this issue in their copy of bb64, see:
 cinder/Cinder#1555

(note: bb64 is public domain and Cinder is BSD-2)
  • Loading branch information
cyrush committed Sep 29, 2016
1 parent 40d6b0f commit b3f6193
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/tests/conduit/t_conduit_json_sanitize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,9 @@ TEST(conduit_json_sanitize, simple_quoteless_schema)
EXPECT_EQ(n5["top"][2].as_uint32(),d_val);
EXPECT_EQ(n5["other"].as_float64(),e_val);

delete [] data;
delete [] data2;
delete [] data3;
delete [] data4;
}

7 changes: 6 additions & 1 deletion src/thirdparty_builtin/libb64-1.2.1/src/cdecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ int base64_decode_block(const char* code_in, const int length_in, char* plaintex
if (codechar == code_in+length_in)
{
state_in->step = step_a;
state_in->plainchar = *plainchar;
// fix bad mem ref (found with valgrind)
// this fix is adapted from Cinder's bug fix for this issue in
// their copy of bb64, see:
// https://github.com/cinder/Cinder/pull/1555
// (note: bb64 is public domain and Cinder is BSD-2)
state_in->plainchar = 0;
return plainchar - plaintext_out;
}
fragment = (char)base64_decode_value(*codechar++);
Expand Down

0 comments on commit b3f6193

Please sign in to comment.