Finish implementation of copy method.

All types (besides EntropyVal) now support a native copy operation,
which uses primitives of the underlying datatypes to perform a quick
copy, without serialization.

EntropyVal is the one exception - since that type is rather complex
(many members) and will probably not be copied a lot, if at all, it
makes sense to just use the serialization function.

This will have to be slightly re-written in the near-term-future to use
the new serialization function for that opaque type.

This change also introduces a new x509_from_der bif, which allows to
parse a der into an opaque of x509.

This change removes the d2i_X509_ wrapper function; this was a remnant
when d2i_X509 took non-const arguments. We directly use d2i_X509 at
several places assuming const-ness, so there does not seem to ba a
reason to keep the wrapper.

This change also exposed a problem in the File cache - cases in which an
object was brought back into the cache, and writing occurred in the
file_open event were never correctly handeled as far as I can tell.
This commit is contained in:
Johanna Amann 2019-05-22 11:36:52 -07:00
parent 2efbe76920
commit 74bb7716f6
22 changed files with 280 additions and 33 deletions

View file

@ -109,9 +109,14 @@ Val* Val::DoClone(CloneState* state)
if ( type->Tag() == TYPE_FILE )
{
auto f = AsFile();
::Ref(f);
return new Val(f);
// I think we can just ref the file here - it is unclear what else to do.
// In the case of cached files, I think this is equivalent to what happened before
// - serialization + unserialization just have you the same pointer that you already had.
// In the case of non-cached files, the behavior now is different; in the past, serialize +
// unserialize gave you a new file object because the old one was not in the list anymore. This object
// was automatically opened. This does not happen anymore - instead you get the non-cached pointer back
// which is brought back into the cache when written too.
return Ref();
}
// Fall-through.
@ -3595,7 +3600,7 @@ OpaqueVal::~OpaqueVal()
Val* OpaqueVal::DoClone(CloneState* state)
{
// TODO
reporter->InternalError("cloning opaque type without clone implementation");
return nullptr;
}