summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2016-10-31 14:07:27 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2016-10-31 17:01:22 +0100
commit26277f46b3fe721fb56142f74035d688eac5b882 (patch)
tree8d591663f879e4255676295b7b60d42a48fd5a5b
parenta884d5f6040cd5d50482e975ad6cf5b1ce830f6c (diff)
downloadgnutls-26277f46b3fe721fb56142f74035d688eac5b882.tar.gz
x509_dn: allow arbitrary escaped strings
In addition fail encoding on unescaped '+'. We do not support it for DN encoding.
-rw-r--r--lib/x509/x509_dn.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/x509/x509_dn.c b/lib/x509/x509_dn.c
index 4fa90e5d4b..fc8aeb9c8f 100644
--- a/lib/x509/x509_dn.c
+++ b/lib/x509/x509_dn.c
@@ -86,9 +86,14 @@ int dn_attr_crt_set(set_dn_func f, void *crt, const gnutls_datum_t * name,
return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);
}
+ /* unescape */
for (j=i=0;i<tmp.size;i++) {
if (1+j!=val->size && val->data[j] == '\\' &&
- (val->data[j+1] == ',' || val->data[j+1] == '#' || val->data[j+1] == ' ')) {
+ (val->data[j+1] == ',' || val->data[j+1] == '#' ||
+ val->data[j+1] == ' ' || val->data[j+1] == '+' ||
+ val->data[j+1] == '"' || val->data[j+1] == '<' ||
+ val->data[j+1] == '>' || val->data[j+1] == ';' ||
+ val->data[j+1] == '\\' || val->data[j+1] == '=')) {
tmp.data[i] = val->data[j+1];
j+=2;
tmp.size--;
@@ -149,6 +154,15 @@ static int read_attr_and_val(const char **ptr,
p++;
}
val->size = p - (val->data);
+ *ptr = (void*)p;
+
+ p = val->data;
+ /* check for unescaped '+' - we do not support them */
+ while (*p != 0) {
+ if (*p == '+' && (*(p - 1) != '\\'))
+ return gnutls_assert_val(GNUTLS_E_PARSING_ERROR);
+ p++;
+ }
/* remove spaces from the end */
while(val->size > 0 && c_isspace(val->data[val->size-1])) {
@@ -160,8 +174,6 @@ static int read_attr_and_val(const char **ptr,
if (val->size == 0 || name->size == 0)
return gnutls_assert_val(GNUTLS_E_PARSING_ERROR);
- *ptr = (void *) p;
-
return 0;
}