Commit f64e15d75bdbeb3b4e307ea825788a2a4bc5d683
1 parent
0f27a609
Exists in
master
and in
3 other branches
Changing CRL buffer to dynamic on windows version.
Showing
1 changed file
with
20 additions
and
9 deletions
Show diff stats
src/lib3270/ssl/windows/getcrl.c
| @@ -82,14 +82,25 @@ typedef struct _curldata | @@ -82,14 +82,25 @@ typedef struct _curldata | ||
| 82 | H3270 * hSession; | 82 | H3270 * hSession; |
| 83 | SSL_ERROR_MESSAGE * message; | 83 | SSL_ERROR_MESSAGE * message; |
| 84 | char errbuf[CURL_ERROR_SIZE]; | 84 | char errbuf[CURL_ERROR_SIZE]; |
| 85 | - unsigned char contents[CRL_DATA_LENGTH]; | 85 | + struct { |
| 86 | + size_t length; | ||
| 87 | + unsigned char * contents; | ||
| 88 | + } data; | ||
| 86 | } CURLDATA; | 89 | } CURLDATA; |
| 87 | 90 | ||
| 88 | static inline void lib3270_autoptr_cleanup_CURLDATA(CURLDATA **ptr) | 91 | static inline void lib3270_autoptr_cleanup_CURLDATA(CURLDATA **ptr) |
| 89 | { | 92 | { |
| 90 | debug("%s(%p)",__FUNCTION__,*ptr); | 93 | debug("%s(%p)",__FUNCTION__,*ptr); |
| 91 | if(*ptr) | 94 | if(*ptr) |
| 92 | - lib3270_free(*ptr); | 95 | + { |
| 96 | + CURLDATA *cdata = *ptr; | ||
| 97 | + | ||
| 98 | + if(cdata->data.contents) { | ||
| 99 | + lib3270_free(cdata->data.contents); | ||
| 100 | + cdata->data.contents = NULL; | ||
| 101 | + } | ||
| 102 | + lib3270_free(cdata); | ||
| 103 | + } | ||
| 93 | *ptr = NULL; | 104 | *ptr = NULL; |
| 94 | } | 105 | } |
| 95 | 106 | ||
| @@ -117,17 +128,15 @@ static size_t internal_curl_write_callback(void *contents, size_t size, size_t n | @@ -117,17 +128,15 @@ static size_t internal_curl_write_callback(void *contents, size_t size, size_t n | ||
| 117 | 128 | ||
| 118 | for(ix = 0; ix < realsize; ix++) | 129 | for(ix = 0; ix < realsize; ix++) |
| 119 | { | 130 | { |
| 120 | - if(data->length >= CRL_DATA_LENGTH) | 131 | + if(data->length >= data->data.length) |
| 121 | { | 132 | { |
| 122 | - lib3270_write_log(NULL,"ssl","CRL Data block is bigger than allocated block (%u)", (unsigned int) CRL_DATA_LENGTH); | ||
| 123 | - return 0; | 133 | + data->data.length += (CRL_DATA_LENGTH + realsize); |
| 134 | + data->data.contents = lib3270_realloc(data->data.contents,data->data.length); | ||
| 124 | } | 135 | } |
| 125 | 136 | ||
| 126 | - data->contents[data->length++] = *(ptr++); | 137 | + data->data.contents[data->length++] = *(ptr++); |
| 127 | } | 138 | } |
| 128 | 139 | ||
| 129 | -// debug("\n%s\n-------------------------------------------", data->contents); | ||
| 130 | - | ||
| 131 | return realsize; | 140 | return realsize; |
| 132 | } | 141 | } |
| 133 | 142 | ||
| @@ -297,9 +306,11 @@ int lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) | @@ -297,9 +306,11 @@ int lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) | ||
| 297 | return -1; | 306 | return -1; |
| 298 | } | 307 | } |
| 299 | 308 | ||
| 309 | + trace_ssl(hSession,"CRL Data has %u bytes",(unsigned int) crl_data->length); | ||
| 310 | + | ||
| 300 | if(ct) | 311 | if(ct) |
| 301 | { | 312 | { |
| 302 | - const unsigned char * data = crl_data->contents; | 313 | + const unsigned char * data = crl_data->data.contents; |
| 303 | 314 | ||
| 304 | trace_ssl(crl_data->hSession, "Content-type: %s", ct); | 315 | trace_ssl(crl_data->hSession, "Content-type: %s", ct); |
| 305 | 316 |