summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_strex.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/a_strex.c')
-rw-r--r--src/lib/libcrypto/asn1/a_strex.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/lib/libcrypto/asn1/a_strex.c b/src/lib/libcrypto/asn1/a_strex.c
index 7ddb7662f1..1def6c6549 100644
--- a/src/lib/libcrypto/asn1/a_strex.c
+++ b/src/lib/libcrypto/asn1/a_strex.c
@@ -63,6 +63,7 @@
63#include <openssl/asn1.h> 63#include <openssl/asn1.h>
64 64
65#include "charmap.h" 65#include "charmap.h"
66#include "cryptlib.h"
66 67
67/* ASN1_STRING_print_ex() and X509_NAME_print_ex(). 68/* ASN1_STRING_print_ex() and X509_NAME_print_ex().
68 * Enhanced string and name printing routines handling 69 * Enhanced string and name printing routines handling
@@ -114,14 +115,17 @@ typedef int char_io(void *arg, const void *buf, int len);
114static int do_esc_char(unsigned long c, unsigned char flags, char *do_quotes, char_io *io_ch, void *arg) 115static int do_esc_char(unsigned long c, unsigned char flags, char *do_quotes, char_io *io_ch, void *arg)
115{ 116{
116 unsigned char chflgs, chtmp; 117 unsigned char chflgs, chtmp;
117 char tmphex[11]; 118 char tmphex[HEX_SIZE(long)+3];
119
120 if(c > 0xffffffffL)
121 return -1;
118 if(c > 0xffff) { 122 if(c > 0xffff) {
119 BIO_snprintf(tmphex, 11, "\\W%08lX", c); 123 BIO_snprintf(tmphex, sizeof tmphex, "\\W%08lX", c);
120 if(!io_ch(arg, tmphex, 10)) return -1; 124 if(!io_ch(arg, tmphex, 10)) return -1;
121 return 10; 125 return 10;
122 } 126 }
123 if(c > 0xff) { 127 if(c > 0xff) {
124 BIO_snprintf(tmphex, 11, "\\U%04lX", c); 128 BIO_snprintf(tmphex, sizeof tmphex, "\\U%04lX", c);
125 if(!io_ch(arg, tmphex, 6)) return -1; 129 if(!io_ch(arg, tmphex, 6)) return -1;
126 return 6; 130 return 6;
127 } 131 }
@@ -195,7 +199,7 @@ static int do_buf(unsigned char *buf, int buflen,
195 if(type & BUF_TYPE_CONVUTF8) { 199 if(type & BUF_TYPE_CONVUTF8) {
196 unsigned char utfbuf[6]; 200 unsigned char utfbuf[6];
197 int utflen; 201 int utflen;
198 utflen = UTF8_putc(utfbuf, 6, c); 202 utflen = UTF8_putc(utfbuf, sizeof utfbuf, c);
199 for(i = 0; i < utflen; i++) { 203 for(i = 0; i < utflen; i++) {
200 /* We don't need to worry about setting orflags correctly 204 /* We don't need to worry about setting orflags correctly
201 * because if utflen==1 its value will be correct anyway 205 * because if utflen==1 its value will be correct anyway
@@ -461,7 +465,7 @@ static int do_name_ex(char_io *io_ch, void *arg, X509_NAME *n,
461 if(fn_opt != XN_FLAG_FN_NONE) { 465 if(fn_opt != XN_FLAG_FN_NONE) {
462 int objlen, fld_len; 466 int objlen, fld_len;
463 if((fn_opt == XN_FLAG_FN_OID) || (fn_nid==NID_undef) ) { 467 if((fn_opt == XN_FLAG_FN_OID) || (fn_nid==NID_undef) ) {
464 OBJ_obj2txt(objtmp, 80, fn, 1); 468 OBJ_obj2txt(objtmp, sizeof objtmp, fn, 1);
465 fld_len = 0; /* XXX: what should this be? */ 469 fld_len = 0; /* XXX: what should this be? */
466 objbuf = objtmp; 470 objbuf = objtmp;
467 } else { 471 } else {