~helen-fornazier/shim/trunk

« back to all changes in this revision

Viewing changes to Cryptlib/OpenSSL/crypto/x509/x509_obj.c

  • Committer: Mathieu Trudel-Lapierre
  • Date: 2016-09-22 00:29:42 UTC
  • mto: This revision was merged to the branch mainline in revision 107.
  • Revision ID: mathieu.trudel-lapierre@canonical.com-20160922002942-volexao40gxxs0qs
Tags: upstream-0.9+1474479173.6c180c6
ImportĀ upstreamĀ versionĀ 0.9+1474479173.6c180c6

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
#include <openssl/x509.h>
64
64
#include <openssl/buffer.h>
65
65
 
 
66
/*
 
67
 * Limit to ensure we don't overflow: much greater than
 
68
 * anything enountered in practice.
 
69
 */
 
70
 
 
71
#define NAME_ONELINE_MAX    (1024 * 1024)
 
72
 
66
73
char *X509_NAME_oneline(X509_NAME *a, char *buf, int len)
67
74
{
68
75
    X509_NAME_ENTRY *ne;
86
93
            goto err;
87
94
        b->data[0] = '\0';
88
95
        len = 200;
 
96
    } else if (len == 0) {
 
97
        return NULL;
89
98
    }
90
99
    if (a == NULL) {
91
100
        if (b) {
110
119
 
111
120
        type = ne->value->type;
112
121
        num = ne->value->length;
 
122
        if (num > NAME_ONELINE_MAX) {
 
123
            X509err(X509_F_X509_NAME_ONELINE, X509_R_NAME_TOO_LONG);
 
124
            goto end;
 
125
        }
113
126
        q = ne->value->data;
114
127
#ifdef CHARSET_EBCDIC
115
128
        if (type == V_ASN1_GENERALSTRING ||
117
130
            type == V_ASN1_PRINTABLESTRING ||
118
131
            type == V_ASN1_TELETEXSTRING ||
119
132
            type == V_ASN1_VISIBLESTRING || type == V_ASN1_IA5STRING) {
120
 
            ascii2ebcdic(ebcdic_buf, q, (num > sizeof ebcdic_buf)
121
 
                         ? sizeof ebcdic_buf : num);
 
133
            if (num > (int)sizeof(ebcdic_buf))
 
134
                num = sizeof(ebcdic_buf);
 
135
            ascii2ebcdic(ebcdic_buf, q, num);
122
136
            q = ebcdic_buf;
123
137
        }
124
138
#endif
154
168
 
155
169
        lold = l;
156
170
        l += 1 + l1 + 1 + l2;
 
171
        if (l > NAME_ONELINE_MAX) {
 
172
            X509err(X509_F_X509_NAME_ONELINE, X509_R_NAME_TOO_LONG);
 
173
            goto end;
 
174
        }
157
175
        if (b != NULL) {
158
176
            if (!BUF_MEM_grow(b, l + 1))
159
177
                goto err;
206
224
    return (p);
207
225
 err:
208
226
    X509err(X509_F_X509_NAME_ONELINE, ERR_R_MALLOC_FAILURE);
209
 
    if (b != NULL)
210
 
        BUF_MEM_free(b);
 
227
 end:
 
228
    BUF_MEM_free(b);
211
229
    return (NULL);
212
230
}