aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Bottomley <JBottomley@Parallels.com>2012-12-12 12:02:08 +0000
committerJames Bottomley <JBottomley@Parallels.com>2012-12-12 12:02:08 +0000
commit0c4c1f546f5b27797315514027de7ae2feb36557 (patch)
treef443b049d16f82483c65dd9646303c8126e2f656
parent497a491a0b1a9a402a0478a7bdadb64a20782a78 (diff)
downloadefitools-0c4c1f546f5b27797315514027de7ae2feb36557.tar.gz
identification: work in both EFI and non-EFI environments
All ASN1 strings are ASCII like encodings. To display this in the EFI SPrint() and equivalents you have to use %a. However for normal printf this has to be %s, so abstract this difference Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--lib/asn1/identification.c6
-rw-r--r--lib/asn1/typedefs.h3
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/asn1/identification.c b/lib/asn1/identification.c
index 3068209..73cc96b 100644
--- a/lib/asn1/identification.c
+++ b/lib/asn1/identification.c
@@ -175,11 +175,11 @@ void dntoa(chunk_t dn, STR *buf, size_t len)
if (oid == OID_UNKNOWN)
{
- written = snprintf(buf, len, "%#B=", &oid_data);
+ written = snprintf(buf, len, "UNKNOWN-OID=");
}
else
{
- written = snprintf(buf, len,"%a=", oid_names[oid].name);
+ written = snprintf(buf, len,"%" STRA "=", oid_names[oid].name);
}
if (written < 0 || written >= len)
{
@@ -189,7 +189,7 @@ void dntoa(chunk_t dn, STR *buf, size_t len)
len -= written;
chunk_printable(data, &printable, '?');
- written = snprintf(buf, len, "%.*a", (int)printable.len, printable.ptr);
+ written = snprintf(buf, len, "%.*" STRA, (int)printable.len, printable.ptr);
chunk_free(&printable);
if (written < 0 || written >= len)
{
diff --git a/lib/asn1/typedefs.h b/lib/asn1/typedefs.h
index fc861ef..756a629 100644
--- a/lib/asn1/typedefs.h
+++ b/lib/asn1/typedefs.h
@@ -10,7 +10,9 @@
#define isprint(x) (1)
#define snprintf(s, l, f...) SPrint(s, l, L ## f)
+/* STR is the native string and STRA is how to printf and ASCII string */
#define STR CHAR16
+#define STRA "a"
#define size_t UINTN
static inline void
@@ -43,6 +45,7 @@ typedef unsigned char u_char;
#include <time.h>
#define STR char
+#define STRA "s"
#define FALSE 0
#define TRUE 1