diff options
author | Nikos <nmav@crystal.(none)> | 2007-11-28 20:46:08 +0200 |
---|---|---|
committer | Nikos <nmav@crystal.(none)> | 2007-11-28 20:46:08 +0200 |
commit | a05d9548df39c534cb736266e6d651548fefcc19 (patch) | |
tree | 17741c663d7a01a4249c1ef44e205b45cdab5dae /lib | |
parent | 943769c78a74f09398a1b7171a5fdc620cae3bb1 (diff) | |
download | gnutls-a05d9548df39c534cb736266e6d651548fefcc19.tar.gz |
Return the string position in case of an error in the priority functions.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gnutls_priority.c | 26 | ||||
-rw-r--r-- | lib/gnutlsxx.cpp | 4 |
2 files changed, 16 insertions, 14 deletions
diff --git a/lib/gnutls_priority.c b/lib/gnutls_priority.c index 8147767c17..9ac24b09b3 100644 --- a/lib/gnutls_priority.c +++ b/lib/gnutls_priority.c @@ -421,8 +421,7 @@ gnutls_priority_set (gnutls_session_t session, gnutls_priority_t priority) * gnutls_priority_init - Sets priorities for the cipher suites supported by gnutls. * @priority_cache: is a #gnutls_prioritity_t structure. * @priorities: is a string describing priorities - * @syntax_error: In case of an error an error string will be copied there. - * @syntax_error_size: the length of the previous string. + * @err_pos: In case of an error this will have the position in the string the error occured * * Sets priorities for the ciphers, key exchange methods, macs and * compression methods. This is to avoid using the @@ -482,8 +481,7 @@ gnutls_priority_set (gnutls_session_t session, gnutls_priority_t priority) **/ int gnutls_priority_init (gnutls_priority_t * priority_cache, - const char *priorities, char *syntax_error, - size_t syntax_error_size) + const char *priorities, const char **err_pos) { char *broken_list[MAX_ELEMENTS]; int broken_list_size, i; @@ -603,10 +601,16 @@ gnutls_priority_init (gnutls_priority_t * priority_cache, return 0; error: + if (err_pos != NULL && i < broken_list_size) + { + *err_pos = priorities; + for (j = 0; j < i; j++) + { + (*err_pos) += strlen (broken_list[j]) + 1; + } + } gnutls_free (darg); - if (syntax_error != NULL) - snprintf (syntax_error, syntax_error_size, "Unknown element: %s", - broken_list[i]); + return GNUTLS_E_INVALID_REQUEST; } @@ -629,8 +633,7 @@ gnutls_priority_deinit (gnutls_priority_t priority_cache) * gnutls_priority_set_direct - Sets priorities for the cipher suites supported by gnutls. * @session: is a #gnutls_session_t structure. * @priorities: is a string describing priorities - * @syntax_error: In case of an error an error string will be copied there. - * @syntax_error_size: the length of the previous string. + * @err_pos: In case of an error this will have the position in the string the error occured * * Sets the priorities to use on the ciphers, key exchange methods, * macs and compression methods. This function avoids keeping a @@ -642,13 +645,12 @@ gnutls_priority_deinit (gnutls_priority_t priority_cache) **/ int gnutls_priority_set_direct (gnutls_session_t session, const char *priorities, - char *syntax_error, size_t syntax_error_size) + const char **err_pos) { gnutls_priority_t prio; int ret; - ret = - gnutls_priority_init (&prio, priorities, syntax_error, syntax_error_size); + ret = gnutls_priority_init (&prio, priorities, err_pos); if (ret < 0) { gnutls_assert (); diff --git a/lib/gnutlsxx.cpp b/lib/gnutlsxx.cpp index b5e8c99da9..815dae103c 100644 --- a/lib/gnutlsxx.cpp +++ b/lib/gnutlsxx.cpp @@ -187,9 +187,9 @@ void session::set_certificate_type_priority (const int *list) /* if you just want some defaults, use the following. */ -void session::set_priority(const char* prio, char* syntax_error, size_t syntax_error_size) +void session::set_priority(const char* prio, const char** err_pos) { - RETWRAP(gnutls_priority_set_direct( this->s, prio, syntax_error, syntax_error_size)); + RETWRAP(gnutls_priority_set_direct( this->s, prio, err_pos)); } void session::set_priority(gnutls_priority_t p) |