diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2002-11-02 08:41:43 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2002-11-02 08:41:43 +0000 |
commit | dfa6f7f9054dd87642c38ff189b4f01d88c88a89 (patch) | |
tree | 3675be9cdb0ef4aeb678b31dbbcbb902bafbf911 /lib | |
parent | d340158164411d7eef49550781dc147689864b89 (diff) | |
download | gnutls-dfa6f7f9054dd87642c38ff189b4f01d88c88a89.tar.gz |
Combined GNUTLS_E_INVALID_PARAMETERS wich GNUTLS_E_INVALID_REQUEST. Introduced GNUTLS_E_SHORT_MEMORY_BUFFER.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ext_cert_type.c | 11 | ||||
-rw-r--r-- | lib/ext_max_record.c | 11 | ||||
-rw-r--r-- | lib/ext_server_name.c | 11 | ||||
-rw-r--r-- | lib/gnutls_alert.c | 2 | ||||
-rw-r--r-- | lib/gnutls_buffers.c | 14 | ||||
-rw-r--r-- | lib/gnutls_cert.c | 2 | ||||
-rw-r--r-- | lib/gnutls_dh_primes.c | 6 | ||||
-rw-r--r-- | lib/gnutls_errors.c | 6 | ||||
-rw-r--r-- | lib/gnutls_errors_int.h | 6 | ||||
-rw-r--r-- | lib/gnutls_handshake.c | 2 | ||||
-rw-r--r-- | lib/gnutls_record.c | 4 | ||||
-rw-r--r-- | lib/gnutls_rsa_export.c | 6 | ||||
-rw-r--r-- | lib/gnutls_session_pack.c | 6 | ||||
-rw-r--r-- | lib/gnutls_ui.c | 2 | ||||
-rw-r--r-- | lib/x509_b64.c | 8 |
15 files changed, 48 insertions, 49 deletions
diff --git a/lib/ext_cert_type.c b/lib/ext_cert_type.c index 26a2252f1e..407074dfd9 100644 --- a/lib/ext_cert_type.c +++ b/lib/ext_cert_type.c @@ -89,7 +89,7 @@ int _gnutls_cert_type_recv_params( gnutls_session session, const opaque* data, s if (new_type < 0) { gnutls_assert(); - return GNUTLS_E_ILLEGAL_PARAMETER; + return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER; } if ( (ret=_gnutls_session_cert_type_supported( session, new_type)) < 0) { @@ -107,7 +107,6 @@ int _gnutls_cert_type_recv_params( gnutls_session session, const opaque* data, s } /* returns data_size or a negative number on failure - * data is allocated localy */ int _gnutls_cert_type_send_params( gnutls_session session, opaque* data, size_t data_size) { uint len, i; @@ -130,7 +129,7 @@ int _gnutls_cert_type_send_params( gnutls_session session, opaque* data, size_t if (data_size < len + 1) { gnutls_assert(); - return GNUTLS_E_INVALID_REQUEST; + return GNUTLS_E_SHORT_MEMORY_BUFFER; } /* this is a vector! @@ -150,7 +149,7 @@ int _gnutls_cert_type_send_params( gnutls_session session, opaque* data, size_t len = 1; if (data_size < len) { gnutls_assert(); - return GNUTLS_E_INVALID_REQUEST; + return GNUTLS_E_SHORT_MEMORY_BUFFER; } data[0] = _gnutls_cert_type2num( session->security_parameters.cert_type); @@ -173,7 +172,7 @@ int _gnutls_num2cert_type( int num) { case 1: return GNUTLS_CRT_OPENPGP; default: - return GNUTLS_E_ILLEGAL_PARAMETER; + return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER; } } @@ -187,7 +186,7 @@ int _gnutls_cert_type2num( int cert_type) { case GNUTLS_CRT_OPENPGP: return 1; default: - return GNUTLS_E_ILLEGAL_PARAMETER; + return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER; } } diff --git a/lib/ext_max_record.c b/lib/ext_max_record.c index 09a230e238..0b00f4b0af 100644 --- a/lib/ext_max_record.c +++ b/lib/ext_max_record.c @@ -70,7 +70,7 @@ int _gnutls_max_record_recv_params( gnutls_session session, const opaque* data, if (new_size < 0 || new_size != session->internals.proposed_record_size) { gnutls_assert(); - return GNUTLS_E_ILLEGAL_PARAMETER; + return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER; } else { session->security_parameters.max_record_recv_size = session->internals.proposed_record_size; } @@ -84,7 +84,6 @@ int _gnutls_max_record_recv_params( gnutls_session session, const opaque* data, } /* returns data_size or a negative number on failure - * data is allocated localy */ int _gnutls_max_record_send_params( gnutls_session session, opaque* data, size_t data_size) @@ -99,7 +98,7 @@ int _gnutls_max_record_send_params( gnutls_session session, opaque* data, len = 1; if (data_size < len) { gnutls_assert(); - return GNUTLS_E_INVALID_REQUEST; + return GNUTLS_E_SHORT_MEMORY_BUFFER; } data[0] = (uint8) _gnutls_mre_record2num( session->internals.proposed_record_size); @@ -112,7 +111,7 @@ int _gnutls_max_record_send_params( gnutls_session session, opaque* data, len = 1; if (data_size < len) { gnutls_assert(); - return GNUTLS_E_INVALID_REQUEST; + return GNUTLS_E_SHORT_MEMORY_BUFFER; } data[0] = (uint8) _gnutls_mre_record2num( session->security_parameters.max_record_recv_size); @@ -139,7 +138,7 @@ int _gnutls_mre_num2record( int num) { case 4: return 4096; default: - return GNUTLS_E_ILLEGAL_PARAMETER; + return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER; } } @@ -157,7 +156,7 @@ int _gnutls_mre_record2num( uint16 record_size) { case 4096: return 4; default: - return GNUTLS_E_ILLEGAL_PARAMETER; + return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER; } } diff --git a/lib/ext_server_name.c b/lib/ext_server_name.c index c94a68d67c..de0185ab50 100644 --- a/lib/ext_server_name.c +++ b/lib/ext_server_name.c @@ -111,7 +111,6 @@ int _gnutls_server_name_recv_params(gnutls_session session, } /* returns data_size or a negative number on failure - * data is allocated localy */ int _gnutls_server_name_send_params(gnutls_session session, opaque * data, size_t _data_size) @@ -141,7 +140,7 @@ int _gnutls_server_name_send_params(gnutls_session session, opaque * data, /* UINT16: write total size of all names */ - DECR_LENGTH_RET( data_size, 2, GNUTLS_E_INVALID_REQUEST); + DECR_LENGTH_RET( data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER); _gnutls_write_uint16(total_size, p); p += 2; @@ -161,7 +160,7 @@ int _gnutls_server_name_send_params(gnutls_session session, opaque * data, * UINT16: size of the first name * LEN: the actual server name. */ - DECR_LENGTH_RET( data_size, len + 3, GNUTLS_E_INVALID_REQUEST); + DECR_LENGTH_RET( data_size, len + 3, GNUTLS_E_SHORT_MEMORY_BUFFER); *p = 0; /* NAME_DNS type */ p++; @@ -200,7 +199,7 @@ int _gnutls_server_name_send_params(gnutls_session session, opaque * data, * that support virtual hosting, and the data will be null terminated. * The client may give the server the dnsname they connected to. * - * If data has not enough size to hold the server name GNUTLS_E_INVALID_REQUEST + * If data has not enough size to hold the server name GNUTLS_E_SHORT_MEMORY_BUFFER * is returned, and data_length will hold the required size. * * 'index' is used to retrieve more than one server names (if sent by the client). @@ -241,7 +240,7 @@ int gnutls_get_server_name(gnutls_session session, void *data, *data_length = session->security_parameters.extensions.server_names[index]. name_length; - return GNUTLS_E_INVALID_REQUEST; + return GNUTLS_E_SHORT_MEMORY_BUFFER; } return 0; @@ -273,7 +272,7 @@ int gnutls_set_server_name(gnutls_session session, return GNUTLS_E_INVALID_REQUEST; if (name_length > MAX_SERVER_NAME_SIZE) - return GNUTLS_E_INVALID_REQUEST; + return GNUTLS_E_SHORT_MEMORY_BUFFER; server_names = session->security_parameters.extensions.server_names_size + 1; diff --git a/lib/gnutls_alert.c b/lib/gnutls_alert.c index 10e6eafa6b..f5d251ab4f 100644 --- a/lib/gnutls_alert.c +++ b/lib/gnutls_alert.c @@ -141,7 +141,7 @@ int _level = -1; ret = GNUTLS_A_DECOMPRESSION_FAILURE; _level = GNUTLS_AL_FATAL; break; - case GNUTLS_E_ILLEGAL_PARAMETER: + case GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER: ret = GNUTLS_A_ILLEGAL_PARAMETER; _level = GNUTLS_AL_FATAL; break; diff --git a/lib/gnutls_buffers.c b/lib/gnutls_buffers.c index 3e9ad574fd..a5f2d20b7d 100644 --- a/lib/gnutls_buffers.c +++ b/lib/gnutls_buffers.c @@ -98,7 +98,7 @@ int _gnutls_record_buffer_put(ContentType type, gnutls_session session, char *da default: gnutls_assert(); - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } return 0; @@ -115,7 +115,7 @@ int _gnutls_record_buffer_get_size(ContentType type, gnutls_session session) return session->internals.handshake_data_buffer.length; default: - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } return 0; } @@ -139,7 +139,7 @@ int _gnutls_record_buffer_get(ContentType type, gnutls_session session, char *da { if (length==0 || data==NULL) { gnutls_assert(); - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } switch(type) { @@ -183,7 +183,7 @@ int _gnutls_record_buffer_get(ContentType type, gnutls_session session, char *da break; default: gnutls_assert(); - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } @@ -334,7 +334,7 @@ ssize_t _gnutls_io_read_buffered( gnutls_session session, opaque **iptr, size_t || (session->internals.record_recv_buffer.length+sizeOfPtr) > MAX_RECV_SIZE) { gnutls_assert(); /* internal error */ - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } /* leave peeked data to the kernel space only if application data @@ -535,7 +535,7 @@ ssize_t _gnutls_io_write_buffered( gnutls_session session, const void *iptr, siz */ if (session->internals.record_send_buffer.length > 0 && iptr != NULL) { gnutls_assert(); - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } /* If data in the buffer exist @@ -804,7 +804,7 @@ ssize_t _gnutls_handshake_io_recv_int( gnutls_session session, ContentType type, if (sizeOfPtr == 0 || iptr == NULL) { gnutls_assert(); - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } if (session->internals.handshake_recv_buffer.length > 0) { diff --git a/lib/gnutls_cert.c b/lib/gnutls_cert.c index 9a46c61bee..308b775405 100644 --- a/lib/gnutls_cert.c +++ b/lib/gnutls_cert.c @@ -195,7 +195,7 @@ int _gnutls_cert_supported_kx(const gnutls_cert * cert, gnutls_kx_algorithm ** a if (i==0) { gnutls_assert(); - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } *alg = gnutls_calloc(1, sizeof(gnutls_kx_algorithm) * i); diff --git a/lib/gnutls_dh_primes.c b/lib/gnutls_dh_primes.c index 2dea0cd3c8..e89a224998 100644 --- a/lib/gnutls_dh_primes.c +++ b/lib/gnutls_dh_primes.c @@ -513,7 +513,7 @@ static int check_bits(int bits) } while (supported_bits[i] != 0); gnutls_assert(); - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } /* Replaces the prime in the static DH parameters, with a randomly @@ -543,7 +543,7 @@ int gnutls_dh_params_set(gnutls_dh_params dh_params, gnutls_datum prime, if (check_bits(bits) < 0) { gnutls_assert(); - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } i = 0; @@ -681,7 +681,7 @@ int gnutls_dh_params_generate(gnutls_datum * prime, if (check_bits(bits) < 0) { gnutls_assert(); - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } if (_gnutls_dh_generate_prime(&tmp_g, &tmp_prime, bits) < 0) { diff --git a/lib/gnutls_errors.c b/lib/gnutls_errors.c index c2e6078e6f..087b580eb2 100644 --- a/lib/gnutls_errors.c +++ b/lib/gnutls_errors.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000 Nikos Mavroyanopoulos + * Copyright (C) 2000,2001,2002 Nikos Mavroyanopoulos * * This file is part of GNUTLS. * @@ -96,9 +96,9 @@ static gnutls_error_entry error_algorithms[] = { ERROR_ENTRY("TLS Application data were received, while expected handshake data.", GNUTLS_E_GOT_APPLICATION_DATA, 1 ), ERROR_ENTRY("Error in Database backend.", GNUTLS_E_DB_ERROR, 1 ), ERROR_ENTRY("The certificate type is not supported.", GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE, 1 ), - ERROR_ENTRY("Invalid parameters given in request.", GNUTLS_E_INVALID_PARAMETERS, 1 ), + ERROR_ENTRY("The memory buffer given, is too short to hold parameters.", GNUTLS_E_SHORT_MEMORY_BUFFER, 1 ), ERROR_ENTRY("The request is invalid.", GNUTLS_E_INVALID_REQUEST, 1 ), - ERROR_ENTRY("An illegal parameter has been received.", GNUTLS_E_ILLEGAL_PARAMETER, 1 ), + ERROR_ENTRY("An illegal parameter has been received.", GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER, 1 ), ERROR_ENTRY("Error while reading file.", GNUTLS_E_FILE_ERROR, 1 ), ERROR_ENTRY("Error in ASCII armoring.", GNUTLS_E_ASCII_ARMOR_ERROR, 1 ), diff --git a/lib/gnutls_errors_int.h b/lib/gnutls_errors_int.h index 224129b5c9..ddd7a4df5d 100644 --- a/lib/gnutls_errors_int.h +++ b/lib/gnutls_errors_int.h @@ -42,12 +42,12 @@ #define GNUTLS_E_X509_UNSUPPORTED_CRITICAL_EXTENSION -47 #define GNUTLS_E_X509_KEY_USAGE_VIOLATION -48 #define GNUTLS_E_NO_CERTIFICATE_FOUND -49 /* GNUTLS_A_BAD_CERTIFICATE */ -#define GNUTLS_E_INVALID_PARAMETERS -50 -#define GNUTLS_E_INVALID_REQUEST -51 +#define GNUTLS_E_INVALID_REQUEST -50 +#define GNUTLS_E_SHORT_MEMORY_BUFFER -51 #define GNUTLS_E_INTERRUPTED -52 #define GNUTLS_E_PUSH_ERROR -53 #define GNUTLS_E_PULL_ERROR -54 -#define GNUTLS_E_ILLEGAL_PARAMETER -55 /* GNUTLS_A_ILLEGAL_PARAMETER */ +#define GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER -55 /* GNUTLS_A_ILLEGAL_PARAMETER */ #define GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE -56 #define GNUTLS_E_PKCS1_WRONG_PAD -57 #define GNUTLS_E_RECEIVED_ILLEGAL_EXTENSION -58 diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c index 06bfb421b3..ddc5e65184 100644 --- a/lib/gnutls_handshake.c +++ b/lib/gnutls_handshake.c @@ -736,7 +736,7 @@ int _gnutls_send_handshake(gnutls_session session, void *i_data, if (i_data == NULL && i_datasize > 0) { gnutls_assert(); - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } /* first run */ diff --git a/lib/gnutls_record.c b/lib/gnutls_record.c index cefcb0d896..1aca855a77 100644 --- a/lib/gnutls_record.c +++ b/lib/gnutls_record.c @@ -305,7 +305,7 @@ ssize_t gnutls_send_int( gnutls_session session, ContentType type, HandshakeType if (session->internals.record_send_buffer.length == 0 && (sizeofdata == 0 || _data==NULL)) { gnutls_assert(); - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } if (type!=GNUTLS_ALERT) /* alert messages are sent anyway */ @@ -694,7 +694,7 @@ ssize_t gnutls_recv_int( gnutls_session session, ContentType type, HandshakeType ret = 0; if (sizeofdata == 0 || data == NULL) { - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } if ( _gnutls_session_is_valid(session)!=0 || session->internals.may_read!=0) { diff --git a/lib/gnutls_rsa_export.c b/lib/gnutls_rsa_export.c index 5150c37465..5a26aa9acc 100644 --- a/lib/gnutls_rsa_export.c +++ b/lib/gnutls_rsa_export.c @@ -162,7 +162,7 @@ static int check_bits(int bits) } while (supported_bits[i] != 0); gnutls_assert(); - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } #define FREE_PRIVATE_PARAMS for (i=0;i<RSA_PRIVATE_PARAMS;i++) \ @@ -198,7 +198,7 @@ int gnutls_rsa_params_set(gnutls_rsa_params rsa_params, if (check_bits(bits) < 0) { gnutls_assert(); - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } for (i=0;i<RSA_PRIVATE_PARAMS;i++) { @@ -330,7 +330,7 @@ int gnutls_rsa_params_generate(gnutls_datum * m, gnutls_datum *e, if (check_bits(bits) < 0) { gnutls_assert(); - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } ret = _gnutls_rsa_generate_params( rsa_params, bits); diff --git a/lib/gnutls_session_pack.c b/lib/gnutls_session_pack.c index 1c1ade4c20..f86ba8111c 100644 --- a/lib/gnutls_session_pack.c +++ b/lib/gnutls_session_pack.c @@ -65,7 +65,7 @@ int _gnutls_session_pack(gnutls_session session, gnutls_datum * packed_session) if (info == NULL && session->gnutls_key->auth_info_size!=0) { gnutls_assert(); - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } pack_size = session->gnutls_key->auth_info_size; @@ -91,7 +91,7 @@ int _gnutls_session_pack(gnutls_session session, gnutls_datum * packed_session) _gnutls_get_auth_info(session); if (info == NULL && session->gnutls_key->auth_info_size!=0) { gnutls_assert(); - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } packed_session->size = @@ -114,7 +114,7 @@ int _gnutls_session_pack(gnutls_session session, gnutls_datum * packed_session) _gnutls_get_auth_info(session); if (info == NULL && session->gnutls_key->auth_info_size!=0) { gnutls_assert(); - return GNUTLS_E_INVALID_PARAMETERS; + return GNUTLS_E_INVALID_REQUEST; } ret = diff --git a/lib/gnutls_ui.c b/lib/gnutls_ui.c index 4d6d284111..defaad9476 100644 --- a/lib/gnutls_ui.c +++ b/lib/gnutls_ui.c @@ -282,7 +282,7 @@ int gnutls_x509_fingerprint(GNUTLS_DigestAlgorithm algo, const gnutls_datum* dat if (hash_len < 0 || (size_t)hash_len > *result_size) { *result_size = hash_len; - return GNUTLS_E_INVALID_REQUEST; + return GNUTLS_E_SHORT_MEMORY_BUFFER; } *result_size = hash_len; diff --git a/lib/x509_b64.c b/lib/x509_b64.c index 3144ae3dda..6ba8db8bf1 100644 --- a/lib/x509_b64.c +++ b/lib/x509_b64.c @@ -259,7 +259,7 @@ int _gnutls_fbase64_encode(const char *msg, const uint8 * data, int data_size, * * This function will convert the given data to printable data, using the base64 * encoding. This is the encoding used in PEM messages. If the provided - * buffer is not long enough GNUTLS_E_INVALID_REQUEST is returned. + * buffer is not long enough GNUTLS_E_SHORT_MEMORY_BUFFER is returned. * **/ int gnutls_pem_base64_encode( const char* msg, const gnutls_datum *data, char* result, int* result_size) { @@ -273,7 +273,7 @@ int size; if (result==NULL || *result_size < size) { gnutls_free(ret); *result_size = size; - return GNUTLS_E_INVALID_REQUEST; + return GNUTLS_E_SHORT_MEMORY_BUFFER; } else { memcpy( result, ret, size); gnutls_free(ret); @@ -476,6 +476,8 @@ int _gnutls_fbase64_decode( const opaque* header, const opaque * data, size_t da * * Note that b64_data should be null terminated. * + * Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer given is not long enough, + * or 0 on success. **/ int gnutls_pem_base64_decode( const char* header, const gnutls_datum *b64_data, char* result, int* result_size) { @@ -489,7 +491,7 @@ int size; if (result==NULL || *result_size < size) { gnutls_free(ret); *result_size = size; - return GNUTLS_E_INVALID_REQUEST; + return GNUTLS_E_SHORT_MEMORY_BUFFER; } else { memcpy( result, ret, size); gnutls_free(ret); |