diff options
author | Andrew Bartlett <abartlet@samba.org> | 2010-01-12 18:16:45 +1100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2010-03-27 11:51:27 +1100 |
commit | 89eaef025376339ef25d07cdc4748920fceaa968 (patch) | |
tree | f514f4632c9d54a372a7f1f0ca845a0c3a488fbf /source4/heimdal/lib/asn1/extra.c | |
parent | fac8ca52ade6e490eea3cf3d0fc98287da321c13 (diff) | |
download | samba-89eaef025376339ef25d07cdc4748920fceaa968.tar.gz samba-89eaef025376339ef25d07cdc4748920fceaa968.tar.bz2 samba-89eaef025376339ef25d07cdc4748920fceaa968.zip |
s4:heimdal: import lorikeet-heimdal-201001120029 (commit a5e675fed7c5db8a7370b77ed0bfa724196aa84d)
Diffstat (limited to 'source4/heimdal/lib/asn1/extra.c')
-rw-r--r-- | source4/heimdal/lib/asn1/extra.c | 42 |
1 files changed, 11 insertions, 31 deletions
diff --git a/source4/heimdal/lib/asn1/extra.c b/source4/heimdal/lib/asn1/extra.c index b244dbb52a..95780a7898 100644 --- a/source4/heimdal/lib/asn1/extra.c +++ b/source4/heimdal/lib/asn1/extra.c @@ -3,6 +3,8 @@ * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * + * Portions Copyright (c) 2009 Apple Inc. All rights reserved. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -40,13 +42,7 @@ int encode_heim_any(unsigned char *p, size_t len, const heim_any *data, size_t *size) { - if (data->length > len) - return ASN1_OVERFLOW; - p -= data->length; - len -= data->length; - memcpy (p+1, data->data, data->length); - *size = data->length; - return 0; + return der_put_octet_string (p, len, data, size); } int @@ -91,8 +87,7 @@ decode_heim_any(const unsigned char *p, size_t len, void free_heim_any(heim_any *data) { - free(data->data); - data->data = NULL; + der_free_octet_string(data); } size_t @@ -104,58 +99,43 @@ length_heim_any(const heim_any *data) int copy_heim_any(const heim_any *from, heim_any *to) { - to->data = malloc(from->length); - if (to->data == NULL && from->length != 0) - return ENOMEM; - memcpy(to->data, from->data, from->length); - to->length = from->length; - return 0; + return der_copy_octet_string(from, to); } int encode_heim_any_set(unsigned char *p, size_t len, const heim_any_set *data, size_t *size) { - return encode_heim_any(p, len, data, size); + return der_put_octet_string (p, len, data, size); } - int decode_heim_any_set(const unsigned char *p, size_t len, heim_any_set *data, size_t *size) { - memset(data, 0, sizeof(*data)); - data->data = malloc(len); - if (data->data == NULL && len != 0) - return ENOMEM; - data->length = len; - memcpy(data->data, p, len); - if (size) *size = len; - return 0; + return der_get_octet_string(p, len, data, size); } void free_heim_any_set(heim_any_set *data) { - free_heim_any(data); + der_free_octet_string(data); } size_t length_heim_any_set(const heim_any *data) { - return length_heim_any(data); + return data->length; } int copy_heim_any_set(const heim_any_set *from, heim_any_set *to) { - return copy_heim_any(from, to); + return der_copy_octet_string(from, to); } int heim_any_cmp(const heim_any_set *p, const heim_any_set *q) { - if (p->length != q->length) - return p->length - q->length; - return memcmp(p->data, q->data, p->length); + return der_heim_octet_string_cmp(p, q); } |