From 1b69122810462cff569eb0929230961aa356bae0 Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Sat, 9 Aug 2014 16:26:58 +0100 Subject: sasl: Introduced Curl_sasl_build_spn() for building a SPN Various parts of the libcurl source code build a SPN for inclusion in authentication data. This information is either used by our own native generation routines or passed to authentication functions in third-party libraries such as SSPI. However, some of these instances use fixed buffers rather than dynamically allocated ones and not all of those that should, convert to wide character strings in Unicode builds. Implemented a common function that generates a SPN and performs the wide character conversion where necessary. --- lib/curl_sasl.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib/curl_sasl.c') diff --git a/lib/curl_sasl.c b/lib/curl_sasl.c index a2dfe7755..75efca3e8 100644 --- a/lib/curl_sasl.c +++ b/lib/curl_sasl.c @@ -120,6 +120,26 @@ static CURLcode sasl_digest_get_qop_values(const char *options, int *value) } #endif +#if !defined(USE_WINDOWS_SSPI) +/* + * Curl_sasl_build_spn() + * + * This is used to build a SPN string in the format service/host. + * + * Parameters: + * + * serivce [in] - The service type such as www, smtp, pop or imap. + * instance [in] - The instance name such as the host nme or realm. + * + * Returns a pointer to the newly allocated SPN. + */ +char *Curl_sasl_build_spn(const char *service, const char *host) +{ + /* Generate and return our SPN */ + return aprintf("%s/%s", service, host); +} +#endif + /* * Curl_sasl_create_plain_message() * -- cgit v1.2.3