From 440bfeda58734803a750f0f93b25549b0ab4fa0d Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Wed, 10 Mar 2021 15:17:00 -0600 Subject: [PATCH] asn1: Allow asn1_print to build w/o templating --- lib/asn1/Makefile.am | 3 +++ lib/asn1/asn1_print.c | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/asn1/Makefile.am b/lib/asn1/Makefile.am index 2c7584f38..fa2b4f567 100644 --- a/lib/asn1/Makefile.am +++ b/lib/asn1/Makefile.am @@ -66,6 +66,9 @@ check_PROGRAMS = $(TESTS) asn1_gen_SOURCES = asn1_gen.c asn1_print_SOURCES = asn1_print.c +if ASN1_TEMPLATING +asn1_print_CPPFLAGS = -DASN1_IOS_SUPPORTED +endif check_der_SOURCES = check-der.c check-common.c check-common.h check_template_SOURCES = check-template.c check-common.c check-common.h diff --git a/lib/asn1/asn1_print.c b/lib/asn1/asn1_print.c index 5bb1003af..6e5472a15 100644 --- a/lib/asn1/asn1_print.c +++ b/lib/asn1/asn1_print.c @@ -85,6 +85,7 @@ const struct types { } types[] = { #define ASN1_SYM_INTVAL(n, gn, gns, i) #define ASN1_SYM_OID(n, gn, gns) +#ifdef ASN1_IOS_SUPPORTED #define ASN1_SYM_TYPE(n, gn, gns) \ { \ n, \ @@ -96,6 +97,19 @@ const struct types { (printer)print_ ## gns, \ (releaser)free_ ## gns, \ }, +#else +#define ASN1_SYM_TYPE(n, gn, gns) \ + { \ + n, \ + sizeof(gns), \ + (copyer)copy_ ## gns, \ + (lengther)length_ ## gns, \ + (decoder)decode_ ## gns, \ + (encoder)encode_ ## gns, \ + 0, \ + (releaser)free_ ## gns, \ + }, +#endif #include "cms_asn1_syms.x" #include "digest_asn1_syms.x" #include "krb5_asn1_syms.x" @@ -421,6 +435,9 @@ dotype(unsigned char *buf, size_t len, char **argv, size_t *size) if (print_flag) { char *s = NULL; + if (!sorted_types[i].print) + err(1, "Missing print support; try enabling / not " + "disabling ASN.1 templating in build configuration"); s = sorted_types[i].print(v, indent_flag ? ASN1_PRINT_INDENT : 0); if (!s) { ret = errno;