usr/src/cmd/mysql-5-1/patches/yassl.patch
author Jon Tibble <meths@btinternet.com>
Mon, 04 May 2015 14:04:39 +0100
branchoi_151a
changeset 254 9c2a4ac793f0
parent 8 950f332cc02b
permissions -rw-r--r--
Bash patch catchup including shellshock
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
     1
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
     2
#At file:///home/ram/mysql/b50227-5.0-bugteam/ based on revid:gshchepa@stripped
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
     3
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
     4
 2838 Ramil Kalimullin	2010-01-13
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
     5
      Fix for bug#50227: Pre-auth buffer-overflow in mySQL through yaSSL
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
     6
      
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
     7
      Problem: copying issuer's (or subject's) name tags into an internal
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
     8
      buffer from incoming stream we didn't check the buffer overflow. 
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
     9
      That may lead to memory overrun, crash etc.
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    10
      
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    11
      Fix: ensure we don't overrun the buffer.
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    12
      
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    13
      Note: there's no simple test case (exploit needed).
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    14
     @ extra/yassl/taocrypt/include/asn.hpp
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    15
        Fix for bug#50227: Pre-auth buffer-overflow in mySQL through yaSSL
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    16
          - CertDecoder::AddTag() introduced.
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    17
     @ extra/yassl/taocrypt/src/asn.cpp
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    18
        Fix for bug#50227: Pre-auth buffer-overflow in mySQL through yaSSL
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    19
          - copying data from incoming stream to the issuer_ or subject_
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    20
        buffers ensure we don't overrun them.
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    21
          - code cleanup.
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    22
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    23
    modified:
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    24
      extra/yassl/taocrypt/include/asn.hpp
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    25
      extra/yassl/taocrypt/src/asn.cpp
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    26
=== modified file 'extra/yassl/taocrypt/include/asn.hpp'
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    27
--- a/extra/yassl/taocrypt/include/asn.hpp	2007-01-29 15:54:40 +0000
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    28
+++ b/extra/yassl/taocrypt/include/asn.hpp	2010-01-13 05:20:45 +0000
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    29
@@ -305,6 +305,7 @@ private:
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    30
     bool   ValidateSignature(SignerList*);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    31
     bool   ConfirmSignature(Source&);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    32
     void   GetKey();
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    33
+    char*  AddTag(char*, const char*, const char*, word32, word32);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    34
     void   GetName(NameType);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    35
     void   GetValidity();
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    36
     void   GetDate(DateType);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    37
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    38
=== modified file 'extra/yassl/taocrypt/src/asn.cpp'
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    39
--- a/extra/yassl/taocrypt/src/asn.cpp	2009-06-29 13:17:01 +0000
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    40
+++ b/extra/yassl/taocrypt/src/asn.cpp	2010-01-13 05:20:45 +0000
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    41
@@ -652,6 +652,23 @@ word32 CertDecoder::GetDigest()
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    42
 }
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    43
 
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    44
 
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    45
+char *CertDecoder::AddTag(char *ptr, const char *buf_end, 
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    46
+                          const char *tag_name, word32 tag_name_length,
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    47
+                          word32 tag_value_length)
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    48
+{
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    49
+  if (ptr + tag_name_length + tag_value_length > buf_end)
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    50
+      return 0;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    51
+    
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    52
+  memcpy(ptr, tag_name, tag_name_length);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    53
+  ptr+= tag_name_length;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    54
+  
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    55
+  memcpy(ptr, source_.get_current(), tag_value_length);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    56
+  ptr+= tag_value_length;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    57
+  
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    58
+  return ptr;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    59
+}
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    60
+
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    61
+
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    62
 // process NAME, either issuer or subject
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    63
 void CertDecoder::GetName(NameType nt)
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    64
 {
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    65
@@ -659,11 +676,21 @@ void CertDecoder::GetName(NameType nt)
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    66
 
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    67
     SHA    sha;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    68
     word32 length = GetSequence();  // length of all distinguished names
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    69
-    assert (length < ASN_NAME_MAX);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    70
+
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    71
+    if (length >= ASN_NAME_MAX)
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    72
+        goto err;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    73
     length += source_.get_index();
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    74
 
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    75
-    char*  ptr = (nt == ISSUER) ? issuer_ : subject_;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    76
-    word32 idx = 0;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    77
+    char *ptr, *buf_end;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    78
+
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    79
+    if (nt == ISSUER) {
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    80
+        ptr= issuer_;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    81
+        buf_end= ptr + sizeof(issuer_) - 1;  // 1 byte for trailing 0
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    82
+    }
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    83
+    else {
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    84
+        ptr= subject_;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    85
+        buf_end= ptr + sizeof(subject_) - 1;  // 1 byte for trailing 0
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    86
+    }
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    87
 
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    88
     while (source_.get_index() < length) {
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    89
         GetSet();
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    90
@@ -685,47 +712,36 @@ void CertDecoder::GetName(NameType nt)
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    91
             byte   id      = source_.next();  
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    92
             b              = source_.next();    // strType
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    93
             word32 strLen  = GetLength(source_);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    94
-            bool   copy    = false;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    95
 
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    96
-            if (id == COMMON_NAME) {
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    97
-                memcpy(&ptr[idx], "/CN=", 4);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    98
-                idx += 4;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    99
-                copy = true;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   100
-            }
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   101
-            else if (id == SUR_NAME) {
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   102
-                memcpy(&ptr[idx], "/SN=", 4);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   103
-                idx += 4;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   104
-                copy = true;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   105
-            }
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   106
-            else if (id == COUNTRY_NAME) {
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   107
-                memcpy(&ptr[idx], "/C=", 3);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   108
-                idx += 3;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   109
-                copy = true;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   110
-            }
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   111
-            else if (id == LOCALITY_NAME) {
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   112
-                memcpy(&ptr[idx], "/L=", 3);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   113
-                idx += 3;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   114
-                copy = true;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   115
-            }
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   116
-            else if (id == STATE_NAME) {
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   117
-                memcpy(&ptr[idx], "/ST=", 4);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   118
-                idx += 4;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   119
-                copy = true;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   120
-            }
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   121
-            else if (id == ORG_NAME) {
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   122
-                memcpy(&ptr[idx], "/O=", 3);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   123
-                idx += 3;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   124
-                copy = true;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   125
-            }
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   126
-            else if (id == ORGUNIT_NAME) {
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   127
-                memcpy(&ptr[idx], "/OU=", 4);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   128
-                idx += 4;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   129
-                copy = true;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   130
-            }
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   131
-
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   132
-            if (copy) {
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   133
-                memcpy(&ptr[idx], source_.get_current(), strLen);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   134
-                idx += strLen;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   135
+            switch (id) {
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   136
+            case COMMON_NAME:
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   137
+                if (!(ptr= AddTag(ptr, buf_end, "/CN=", 4, strLen)))
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   138
+                  goto err;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   139
+                break;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   140
+            case SUR_NAME:
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   141
+                if (!(ptr= AddTag(ptr, buf_end, "/SN=", 4, strLen)))
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   142
+                  goto err;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   143
+                break;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   144
+            case COUNTRY_NAME:
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   145
+                if (!(ptr= AddTag(ptr, buf_end, "/C=", 3, strLen)))
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   146
+                  goto err;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   147
+                break;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   148
+            case LOCALITY_NAME:
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   149
+                if (!(ptr= AddTag(ptr, buf_end, "/L=", 3, strLen)))
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   150
+                  goto err;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   151
+                break;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   152
+            case STATE_NAME:
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   153
+                if (!(ptr= AddTag(ptr, buf_end, "/ST=", 4, strLen)))
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   154
+                  goto err;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   155
+                break;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   156
+            case ORG_NAME:
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   157
+                if (!(ptr= AddTag(ptr, buf_end, "/O=", 3, strLen)))
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   158
+                  goto err;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   159
+                break;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   160
+            case ORGUNIT_NAME:
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   161
+                if (!(ptr= AddTag(ptr, buf_end, "/OU=", 4, strLen)))
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   162
+                  goto err;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   163
+                break;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   164
             }
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   165
 
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   166
             sha.Update(source_.get_current(), strLen);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   167
@@ -739,23 +755,20 @@ void CertDecoder::GetName(NameType nt)
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   168
             source_.advance(oidSz + 1);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   169
             word32 length = GetLength(source_);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   170
 
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   171
-            if (email) {
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   172
-                memcpy(&ptr[idx], "/emailAddress=", 14);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   173
-                idx += 14;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   174
-
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   175
-                memcpy(&ptr[idx], source_.get_current(), length);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   176
-                idx += length;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   177
-            }
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   178
+            if (email && !(ptr= AddTag(ptr, buf_end, "/emailAddress=", 14, length)))
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   179
+                goto err;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   180
 
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   181
             source_.advance(length);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   182
         }
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   183
     }
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   184
-    ptr[idx++] = 0;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   185
+    *ptr= 0;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   186
 
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   187
-    if (nt == ISSUER)
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   188
-        sha.Final(issuerHash_);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   189
-    else
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   190
-        sha.Final(subjectHash_);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   191
+    sha.Final(nt == ISSUER ? issuerHash_ : subjectHash_);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   192
+        
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   193
+    return;
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   194
+    
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   195
+err:
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   196
+    source_.SetError(CONTENT_E);
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   197
 }
950f332cc02b Import sfw build 134
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   198