summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2016-11-25 10:05:28 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2016-11-25 12:03:57 +0100
commit523e329db10e713e946171c7fae5aa3bb9b3e243 (patch)
tree948e41ae8562e15cca78e1e2f3b92528eca6b866
parent70cd4bc9e78fed825a5b467ea4f760341de6ff10 (diff)
downloadgnutls-tmp-idna-write.tar.gz
Combined checks for printable characterstmp-idna-write
-rw-r--r--lib/x509/common.c10
-rw-r--r--lib/x509/output.c16
2 files changed, 6 insertions, 20 deletions
diff --git a/lib/x509/common.c b/lib/x509/common.c
index d94761517a..c2585ee3fd 100644
--- a/lib/x509/common.c
+++ b/lib/x509/common.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2003-2014 Free Software Foundation, Inc.
+ * Copyright (C) 2015-2016 Red Hat, Inc.
*
* Author: Nikos Mavrogiannopoulos
*
@@ -32,7 +33,6 @@
#include "x509_int.h"
#include "extras/hex.h"
#include <common.h>
-#include <c-ctype.h>
static int
data2hex(const void *data, size_t data_size,
@@ -284,7 +284,6 @@ make_printable_string(unsigned etype, const gnutls_datum_t * input,
{
int printable = 0;
int ret;
- unsigned int i;
if (etype == ASN1_ETYPE_BMP_STRING) {
ret = _gnutls_ucs2_to_utf8(input->data, input->size, out, 1);
@@ -294,15 +293,10 @@ make_printable_string(unsigned etype, const gnutls_datum_t * input,
} else
printable = 1;
} else if (etype == ASN1_ETYPE_TELETEX_STRING) {
- int ascii = 0;
/* HACK: if the teletex string contains only ascii
* characters then treat it as printable.
*/
- for (i = 0; i < input->size; i++)
- if (!c_isprint(input->data[i]))
- ascii = 1;
-
- if (ascii == 0) {
+ if (_gnutls_str_is_print((char*)input->data, input->size)) {
out->data = gnutls_malloc(input->size + 1);
if (out->data == NULL)
return
diff --git a/lib/x509/output.c b/lib/x509/output.c
index db8bb9aa2b..117848f288 100644
--- a/lib/x509/output.c
+++ b/lib/x509/output.c
@@ -31,7 +31,6 @@
#include <num.h>
#include "errors.h"
#include <extras/randomart.h>
-#include <c-ctype.h>
#include "extensions.h"
#include "ip.h"
@@ -47,10 +46,7 @@ print_name(gnutls_buffer_st *str, const char *prefix, unsigned type, gnutls_datu
char *sname = (char*)name->data;
char str_ip[64];
const char *p;
-unsigned non_ascii = 0;
-#ifdef HAVE_LIBIDN
-unsigned i;
-#endif
+unsigned printable = 1;
int ret;
if ((type == GNUTLS_SAN_DNSNAME || type == GNUTLS_SAN_OTHERNAME_XMPP
@@ -67,15 +63,11 @@ int ret;
switch (type) {
case GNUTLS_SAN_DNSNAME:
#ifdef HAVE_LIBIDN
- for (i=0;i<name->size;i++) {
- if (c_isprint(name->data[i]) == 0) {
- non_ascii = 1;
- break;
- }
- }
+ if (!_gnutls_str_is_print((char*)name->data, name->size))
+ printable = 0;
#endif
- if (non_ascii != 0) {
+ if (!printable) {
gnutls_datum_t out;
ret = gnutls_idna_map((char*)name->data, name->size, &out, 0);