[openssl/openssl] ef9a76: Don't treat a CRL distribution point URI as a NUL ...

"'Bob Beck' via openssl-commits" <[email protected]>
Newsgroups gmane.comp.encryption.openssl.cvs
Message-ID <openssl/openssl/push/refs/heads/master/[email protected]>
  Branch: refs/heads/master
  Home:   https://github.com/openssl/openssl
  Commit: ef9a76655168506596240a5a747f65ac08b9df53
      https://github.com/openssl/openssl/commit/ef9a76655168506596240a5a747f65ac08b9df53
  Author: Bob Beck <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M apps/lib/apps.c

  Log Message:
  -----------
  Don't treat a CRL distribution point URI as a NUL terminated string

get_dp_url() returned the internal ASN1_STRING data of a DIST_POINT URI
directly. That data has an explicit length and is not necessarily NUL
terminated, yet load_crl() and the HTTP client it hands the URI to consume
it as a C string, reading past the buffer for a certificate carrying a
primitive-form IA5String URI in its CRL distribution points.

Return an allocated NUL terminated copy of the URI and free it in
load_crl_crldp().

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Andrew Dinh <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Merge-date: Thu Aug 27 13:52:39 2026
Merged-from: https://github.com/openssl/openssl/pull/32178


  Commit: 81e0cf8ea3d2c29073291ead904203634778b32a
      https://github.com/openssl/openssl/commit/81e0cf8ea3d2c29073291ead904203634778b32a
  Author: Bob Beck <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M apps/ca.c

  Log Message:
  -----------
  Don't read an ASN1_STRING data raw and assume it's 0 byte terminated

Fix latent app bug in policy error diagnostics.

Fixes: #32176
Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Andrew Dinh <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Merge-date: Thu Aug 27 13:52:39 2026
Merged-from: https://github.com/openssl/openssl/pull/32178


  Commit: 52a9a4f24750ef15a23343729acad71942c5bc55
      https://github.com/openssl/openssl/commit/52a9a4f24750ef15a23343729acad71942c5bc55
  Author: Bob Beck <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M apps/ca.c

  Log Message:
  -----------
  Don't call strlcpy on a non-string.

Again, ASN1_STRING_get0_data has never been guaranteed to be nul terminated.

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Andrew Dinh <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Merge-date: Thu Aug 27 13:52:40 2026
Merged-from: https://github.com/openssl/openssl/pull/32178


  Commit: 7acab0ef09e15c56d9159f6bc326285fc0b0e2f3
      https://github.com/openssl/openssl/commit/7acab0ef09e15c56d9159f6bc326285fc0b0e2f3
  Author: Bob Beck <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M test/asn1_internal_test.c
    M test/testutil/tests.c

  Log Message:
  -----------
  Fix the tests to not pretend ASN1_STRING's are nul terminated.

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Andrew Dinh <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Merge-date: Thu Aug 27 13:52:41 2026
Merged-from: https://github.com/openssl/openssl/pull/32178


  Commit: f3ad4106b8b81a18616131fe09f8332b38e8bfd3
      https://github.com/openssl/openssl/commit/f3ad4106b8b81a18616131fe09f8332b38e8bfd3
  Author: Bob Beck <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M crypto/asn1/a_mbstr.c
    M crypto/asn1/a_strex.c
    M doc/man3/ASN1_STRING_length.pod
    M test/asn1_internal_test.c

  Log Message:
  -----------
  Make ASN1_STRING_to_UTF8() return a NUL terminated buffer

While it's really pretty foolish to do so (since it can
contain legitimate 0 bytes in the output) Some callers were
treating the returned buffer as a C string, in spite of the fact
that the documentation does not say that it is and a length
is returned.

Unfortunately, this probably stems from the bad habit in
OpenSSL of trying to make things C strings anyway, - The conversion
path already allocated the extra byte and terminated it as if it
is a usable C string.  The same-format path stored exact-length data
from an ASN1_STRING with no NUL, so termination depended on the input
type and how it was constructed.

So be consistent, and NUL terminate the returned buffer in both cases.

We then document that the retured buffer *IS* nul terminated, add
unit tests because of the Beyonce rule, and document in the
warnings that in spite of the output buffer being nul terminated
it is potentially a bad idea to use C string functions on it as
it can contain internal NUL bytes.

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Andrew Dinh <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Merge-date: Thu Aug 27 13:52:42 2026
Merged-from: https://github.com/openssl/openssl/pull/32178


  Commit: c9f0103487d39358a6aae76df7a1f4a38212b8ba
      https://github.com/openssl/openssl/commit/c9f0103487d39358a6aae76df7a1f4a38212b8ba
  Author: Bob Beck <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M crypto/asn1/a_print.c

  Log Message:
  -----------
  Fix one byte overrun in UNIVERSALSTRING_to_string

This function assumed there was one byte more than the
length of the string to add NUL byte termination. Don't
do that.

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Andrew Dinh <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Merge-date: Thu Aug 27 13:52:43 2026
Merged-from: https://github.com/openssl/openssl/pull/32178


  Commit: 62570ca6e93af540907330d50ee581fe82cd18fd
      https://github.com/openssl/openssl/commit/62570ca6e93af540907330d50ee581fe82cd18fd
  Author: Bob Beck <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M crypto/asn1/asn1_lib.c
    M include/internal/cryptlib.h

  Log Message:
  -----------
  Don't strncpy() counted ASN1_STRING data in ossl_sk_ASN1_UTF8STRING2text()

The element data is counted, not a C string, so strncpy() was wrong two
ways: an empty element yields strncpy(p, NULL, 0), which is undefined, and a
value containing an embedded NUL was truncated and zero padded instead of
copied verbatim.

Use memcpy() bounded by the element length, skipping empty elements. The
separator copy becomes a plain memcpy() as well, dropping the "+ 1 to
silence gcc" strncpy() hack. The computed buffer length and terminator are
unchanged.

Note in the documentation that using utf8 values in C strings is a
footgun if they contain NUL bytes internally

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Andrew Dinh <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Merge-date: Thu Aug 27 13:52:44 2026
Merged-from: https://github.com/openssl/openssl/pull/32178


  Commit: b8424c0d848ac2526fc3c7b9a325be000b119fd4
      https://github.com/openssl/openssl/commit/b8424c0d848ac2526fc3c7b9a325be000b119fd4
  Author: Bob Beck <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M crypto/asn1/evp_asn1.c
    M crypto/x509/x509name.c

  Log Message:
  -----------
  Fix unguarded memcpy's asn1_type_get_int_oct()and X509_NAME_get_text_by_OBJ()

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Andrew Dinh <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Merge-date: Thu Aug 27 13:52:45 2026
Merged-from: https://github.com/openssl/openssl/pull/32178


  Commit: b844df54f1f8147ac7fe90ac83613a55c5656682
      https://github.com/openssl/openssl/commit/b844df54f1f8147ac7fe90ac83613a55c5656682
  Author: Bob Beck <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M test/asn1_time_test.c

  Log Message:
  -----------
  Don't assume an ASN1_STRING is nul byte terminated in the test

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Andrew Dinh <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Merge-date: Thu Aug 27 13:52:46 2026
Merged-from: https://github.com/openssl/openssl/pull/32178


  Commit: c2bccf040e772a4b4db52489f99839f7c4e01426
      https://github.com/openssl/openssl/commit/c2bccf040e772a4b4db52489f99839f7c4e01426
  Author: Bob Beck <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M crypto/asn1/asn1_lib.c

  Log Message:
  -----------
  Don't hit the legacy strlen case in ASN1_STRING_copy

This should avoid the warning for calling strlen() on data in gcc

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Andrew Dinh <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Merge-date: Thu Aug 27 13:52:47 2026
Merged-from: https://github.com/openssl/openssl/pull/32178


  Commit: 4f183765aab81df08aa53baf483b26d02ad677bb
      https://github.com/openssl/openssl/commit/4f183765aab81df08aa53baf483b26d02ad677bb
  Author: Bob Beck <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M apps/pkcs12.c
    M crypto/cmp/cmp_status.c
    M crypto/x509/v3_attrdesc.c
    M crypto/x509/v3_cpols.c
    M crypto/x509/v3_san.c
    M crypto/x509/v3_timespec.c
    M crypto/x509/v3_usernotice.c
    M crypto/x509/x_attrib.c

  Log Message:
  -----------
  Sweep for printf UB - don't printf %s NULL

As an asn1_string of length 0 will have NULL data, don't
printf %s NULL.

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Andrew Dinh <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Merge-date: Thu Aug 27 13:52:48 2026
Merged-from: https://github.com/openssl/openssl/pull/32178


  Commit: 430aadec30167839410b9887862b077646cfeab0
      https://github.com/openssl/openssl/commit/430aadec30167839410b9887862b077646cfeab0
  Author: Bob Beck <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M test/recipes/95-test_external_krb5_data/patches/0001-Use-Accessors-for-ASN1_STRING-values-from-OpenSSL.patch

  Log Message:
  -----------
  Fix the kerberos external test patch

Make the patch we use here length safe.

(the original kerb code is not)

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Andrew Dinh <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Merge-date: Thu Aug 27 13:52:49 2026
Merged-from: https://github.com/openssl/openssl/pull/32178


  Commit: 49b7ee56918c75d4f19d11aa8fb436129d484322
      https://github.com/openssl/openssl/commit/49b7ee56918c75d4f19d11aa8fb436129d484322
  Author: Bob Beck <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M crypto/asn1/a_print.c

  Log Message:
  -----------
  Don't hit the legacy strlen case in ASN1_PRINTABLE_type

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Andrew Dinh <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Merge-date: Thu Aug 27 13:52:50 2026
Merged-from: https://github.com/openssl/openssl/pull/32178


  Commit: b5570727c8062fe996b0d0afb5a27806a3c23d56
      https://github.com/openssl/openssl/commit/b5570727c8062fe996b0d0afb5a27806a3c23d56
  Author: Bob Beck <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M include/crypto/asn1.h
    M include/openssl/e_os2.h

  Log Message:
  -----------
  Add OPENSSL_NONSTRING and apply it to ASN1_STRING's data field

OPENSSL_NONSTRING expands to __attribute__((nonstring)) where the compiler
supports it and to nothing otherwise. ASN1_STRING data has an explicit
length and is not necessarily NUL terminated, so marking the field lets GCC
diagnose direct use of it with C string functions such as strlen(), strcpy()
or "%s".

The diagnostic fires only on GCC under an optimised build; other compilers,
including current Clang, accept the attribute but do not warn.

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Andrew Dinh <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Merge-date: Thu Aug 27 13:52:51 2026
Merged-from: https://github.com/openssl/openssl/pull/32178


  Commit: 71a0acd3a5c200a0590499bcd660f437e9cf5efb
      https://github.com/openssl/openssl/commit/71a0acd3a5c200a0590499bcd660f437e9cf5efb
  Author: Bob Beck <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M crypto/pkcs12/p12_utl.c
    M test/asn1_internal_test.c

  Log Message:
  -----------
  Don't do pointer arithmetic on a NULL pointer in OPENSSL_uni2asc

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Andrew Dinh <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Merge-date: Thu Aug 27 13:52:52 2026
Merged-from: https://github.com/openssl/openssl/pull/32178


  Commit: f9f6047e9c0c8011d3c875003d4b03f74e05f295
      https://github.com/openssl/openssl/commit/f9f6047e9c0c8011d3c875003d4b03f74e05f295
  Author: Bob Beck <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M crypto/cmp/cmp_util.c
    M test/cmp_hdr_test.c

  Log Message:
  -----------
  Allow pushing an empty ASN1_UTF8STRING onto a CMP freeText stack

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Andrew Dinh <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Merge-date: Thu Aug 27 13:52:53 2026
Merged-from: https://github.com/openssl/openssl/pull/32178


  Commit: d24764e778d92aff18be5798df1fa8fd65753244
      https://github.com/openssl/openssl/commit/d24764e778d92aff18be5798df1fa8fd65753244
  Author: Bob Beck <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M test/asn1_string_test.c

  Log Message:
  -----------
  Add test coverage for ASN1_UNIVERSALSTRING_to_string

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Andrew Dinh <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Merge-date: Thu Aug 27 13:52:54 2026
Merged-from: https://github.com/openssl/openssl/pull/32178


  Commit: d064df18af85426f7b152ec77c2834d19e87c840
      https://github.com/openssl/openssl/commit/d064df18af85426f7b152ec77c2834d19e87c840
  Author: Bob Beck <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M crypto/asn1/asn1_lib.c
    M test/asn1_string_test.c

  Log Message:
  -----------
  Clamp negative lengths to 0 in ASN1_STRING_set0

A negative length is never valid here, so store an empty string
instead, while taking ownership of the data pointer as usual.

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Andrew Dinh <[email protected]>
Reviewed-by: Nikola Pajkovsky <[email protected]>
Merge-date: Thu Aug 27 13:52:55 2026
Merged-from: https://github.com/openssl/openssl/pull/32178


Compare: https://github.com/openssl/openssl/compare/9da88ee430a0...d064df18af85

To unsubscribe from these emails, change your notification settings at https://github.com/openssl/openssl/settings/notifications

-- 
You received this message because you are subscribed to the Google Groups "openssl-commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/a/openssl.org/d/msgid/openssl-commits/openssl/openssl/push/refs/heads/master/9da88e-d064df%40github.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.