diff --git a/src/core/array.c b/src/core/array.c index 4a7fee2..5fc237a 100644 --- a/src/core/array.c +++ b/src/core/array.c @@ -61,7 +61,7 @@ void lib3270_string_array_free(LIB3270_STRING_ARRAY *array) } } -void lib3270_string_array_append(LIB3270_STRING_ARRAY *array, const char *str) +static void lib3270_string_array_realloc(LIB3270_STRING_ARRAY *array) { if(array->str) { @@ -73,8 +73,23 @@ void lib3270_string_array_append(LIB3270_STRING_ARRAY *array, const char *str) array->length = 0; // Just in case. } +} + +void lib3270_string_array_append(LIB3270_STRING_ARRAY *array, const char *str) +{ + lib3270_string_array_realloc(array); array->str[array->length++] = strdup(str); +} + +void lib3270_string_array_append_with_length(LIB3270_STRING_ARRAY *array, const char *str, size_t length) +{ + lib3270_string_array_realloc(array); + + char * buffer = lib3270_malloc(length+1); + memcpy(buffer,str,length); + buffer[length] = 0; + array->str[array->length++] = buffer; } void lib3270_autoptr_cleanup_LIB3270_STRING_ARRAY(LIB3270_STRING_ARRAY **ptr) diff --git a/src/include/array.h b/src/include/array.h index 4457f1d..151ccde 100644 --- a/src/include/array.h +++ b/src/include/array.h @@ -48,6 +48,8 @@ LIB3270_INTERNAL LIB3270_STRING_ARRAY * lib3270_string_array_new(void); LIB3270_INTERNAL void lib3270_string_array_free(LIB3270_STRING_ARRAY *object); LIB3270_INTERNAL void lib3270_string_array_append(LIB3270_STRING_ARRAY *object, const char *str); + LIB3270_INTERNAL void lib3270_string_array_append_with_length(LIB3270_STRING_ARRAY *array, const char *str, size_t length); + LIB3270_INTERNAL void lib3270_autoptr_cleanup_LIB3270_STRING_ARRAY(LIB3270_STRING_ARRAY **ptr); #endif // LIB3270_ARRAY_H_INCLUDED diff --git a/src/ssl/crl.c b/src/ssl/crl.c index 46f49c2..8687ee7 100644 --- a/src/ssl/crl.c +++ b/src/ssl/crl.c @@ -205,7 +205,7 @@ int lib3270_crl_new_from_dist_points(H3270 *hSession, void *ssl_error, CRL_DIST_ #endif // OpenSSL 1.1.0+ if(data) { - lib3270_string_array_append(uris,(char *) data); + lib3270_string_array_append_with_length(uris,(char *) data, (size_t) ASN1_STRING_length(uri)); } } -- libgit2 0.21.2