Nicolas Williams 50eb3bc245 asn1: Fix 1-byte leaks in der_copy_octet_string()
We sometimes do things like `memset(&cert, 0, sizeof(cert))` then
`copy_Certificate(&cert, &cert_copy)`, and then we end up leaking a
byte in `der_copy_octet_string()` due to it having this code:

```C
der_copy_octet_string (const heim_octet_string *from, heim_octet_string *to)
{
    assert(from->length == 0 || (from->length > 0 && from->data != NULL));
    if (from->length == 0)
	to->data = calloc(1, 1);
    else
	to->data = malloc(from->length);
    ...
}
```

The traces where this happens always involve the `_save` field of
`Name` or `TBSCertificate`.

This code was assuming that length 0 octet strings are expected to have
a non-NULL `data`, probably in case the C library's allocator returns
non-NULL pointers for `malloc(0)`, but then, why not just call
`malloc(0)`?  But calling `malloc(0)` would then still lead to this leak
in on such systems.

Now, `der_free_octet_string()` does unconditionally `free()` the
string's `data`, so the leak really is not there but elsewhere, probably
in `lib/asn1/template.c:_asn1_free()`, but it clearly does
`der_free_octet_string()` the `_save` field of types that have it.
2022-11-30 11:59:45 -06:00
2022-11-01 10:23:47 -05:00
2022-02-11 15:19:58 -06:00
2022-11-22 11:34:54 -05:00
2022-09-16 16:13:50 -04:00
2022-11-22 11:34:54 -05:00
2022-11-17 19:20:08 -06:00
2022-11-02 10:57:55 -05:00
2020-04-15 19:05:21 -05:00
2022-01-20 12:49:19 -05:00
2004-02-12 14:19:16 +00:00
2000-06-07 10:01:25 +00:00
2002-08-21 13:29:08 +00:00
2019-06-07 22:03:05 -04:00
2014-08-23 19:14:10 -07:00
2022-01-14 20:10:19 -06:00
2022-11-15 17:53:54 -06:00
2019-11-20 18:14:44 -05:00
2020-06-26 11:29:15 -04:00
2022-02-12 15:00:59 -06:00
2019-06-09 13:43:47 -04:00
2010-01-05 19:21:45 +01:00

GitHub Build Workflow GitHub Build Workflow GitHub Build Workflow Appveyor-CI build (Windows) Coverage Status

Heimdal

Heimdal is an implementation of:

  • ASN.1/DER,
  • PKIX, and
  • Kerberos.

For information how to install see here.

There are man pages for most of the commands.

Bug reports and bugs are appreciated. Use GitHub issues.

For more information see the project homepage https://heimdal.software/heimdal/ or the mailing lists:

heimdal-announce@heimdal.software low-volume announcement heimdal-discuss@heimdal.software high-volume discussion

send mail to heimdal-announce-subscribe@heimdal.software and heimdal-discuss-subscribe@heimdal.software respectively to subscribe.

Build Status

GitHub Build Workflow GitHub Build Workflow GitHub Build Workflow Appveyor-CI build (Windows) Coverage Status

Languages
C 92.1%
Roff 2.8%
Shell 2.3%
Makefile 0.7%
M4 0.5%
Other 1.4%